-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebObjects.py
More file actions
67 lines (46 loc) · 1.78 KB
/
webObjects.py
File metadata and controls
67 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from webObject import webObject
from random import randrange
from selenium.webdriver.support.ui import Select
class webEdit(webObject):
def set(self, value):
self.element.clear()
self.element.send_keys(value)
def append(self,value):
self.element.send_keys(value)
def click(self):
self.element.click()
class webButton(webObject):
def click(self):
self.element.click()
class webSelect(webObject):
def __init__(self, driver, by, loc):
super(webSelect, self).__init__(driver, by, loc)
self.element = Select(self.element)
def select_by_text(self, value):
self.element.select_by_visible_text(value)
def select_random(self):
option_count = len(self.element.options)
select = randrange(option_count)
self.element.select_by_index(select)
def set(self, value):
self.select_by_text(value)
class webLink(webObject):
def click(self):
self.element.click()
class webElement(webObject):
def click(self):
self.element.click()
class webTable(webObject):
class webTable_row(webObject):
def __init__(self, table, by, loc):
super(webTable.webTable_row, self).__init__(table.element, by, loc)
self.table = table
def find_cell_by_index(self, index):
if index == "first":
return self.element.find_elements_by_tag_name("td")[0]
elif index == 'last':
return self.element.find_elements_by_tag_name("td")[-1]
else:
return self.element.find_elements_by_tag_name("td")[index]
def row_containing_text(self, text):
return webTable.webTable_row(self, "xpath", ".//tr[descendant::text()[contains(., '" + text + "')]]")