-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotes.txt
More file actions
130 lines (92 loc) · 2.73 KB
/
Notes.txt
File metadata and controls
130 lines (92 loc) · 2.73 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Selenium:
quit() close entire browser
close() close single tab/current tab Openn tab using javascript executor and switch using handles
WebDriver methods:
close()
findElement()
findElements()
get(String)
getCurrentUrl()
getPageSource()
getTitle()
getWindowsHandle()
getWindowsHandles()
manage()
navigate()
quit()
switchTo()
Locators
tagName()
id()
name()
className()
linkText()
partialLinktext()
cssSelector()
xPath()
xPath:
Abosulute xpath: '/' : parent to immediate child
Relative xpath: '//': parent to any child
### Syntax: //tag[@AN='AV'] Attribute Name and Value
i) //tag[@AN='AV' and @AN='AV'] Pipeline to combine multiple attributes.
ii) //tag[text()='text value'] text()==.
## Partially dynamic elements
//tag[contains(text(),'text')]
## Completley dynamic elements
Forward traversing: Parent --> Child
Backward traversing: Child --> Immediate parent "/.."
Sibling function: One child --> Another child
Following sibling: //a[.='Advertising']/following::a[1]
Preceeding sibling: //a[.='Advertising']/preceding::a[1]
ancestor function: //a[.='Advertising']/ancestor::div[1]
By group index:
(//input[@value='textbox'])[1]
WebElement functions:
clear()
click()
findElement()
findElements()
getTagName()
getText()
isDisplayed()
isEnabled()
isSelected()
sendKeys(---)
submit()
getScreenShotAs()
element.sendKeys(Keys.CONTROL+"a");
Dropdowns:
single select dropdown - select
multi select dropdown - select and deselect
handle dropdown using select class
Select s = new Select(webElement);
methods:
selectByIndex(int index)
selectByValue(String value)
selectByVisibleText(String value)
deselectAll()
deselectByIndex(int index)
deselectByValue(String value)
deselectByVisibleText(String value)
getAllSelectedOptions() --> List<WebElement>
getFirstSelectedOption() --> WebElement
getOptions() --> List<WebElement>
getWrappedElement() --> WebElement
isMultiple() --> boolean
Mouse hover actions:
Use Action class
Actions act = new Actions(driver);
Hover: act.moveToElement().perfrom()
Drag & drop: act.dragAndDrop(ele1,ele2).perform()
Double click: act.doubleClick(doubleClick).perform();
Right click: act.contextClick(rightClick).perform();
Robot class == right click == action class
Handle popups
Hidden division popup - findElement()
Alert and confirmation popup - driver.switchTo().alert(); admit(); dismiss();
File download popup - Robot class
File upload popup - sendKeys(path to file)
Child browser popup - getWindowHandle(); / getWindowHandles();
divison.switchTo().window(id of browser)
TestNG:
BeforeSuite, beforeTest, Test1, AfterMethod, Test2, AfterMethod, AfterTest, AfterSuite