@@ -6,7 +6,6 @@ describe('Element Locator Test', function () {
6
6
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
7
7
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
8
8
const element = await driver . findElement ( By . className ( 'information' ) ) ;
9
-
10
9
const tag = await element . getTagName ( ) ;
11
10
const id = await element . getAttribute ( "id" ) ;
12
11
const value = await element . getAttribute ( "value" ) ;
@@ -50,69 +49,71 @@ describe('Element Locator Test', function () {
50
49
it ( 'Check if element can be found by name' , async function ( ) {
51
50
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
52
51
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
53
- const element = await driver . findElement ( By . name ( "gender " ) ) ;
52
+ const element = await driver . findElement ( By . name ( "newsletter " ) ) ;
54
53
55
54
const tag = await element . getTagName ( ) ;
56
55
const type = await element . getAttribute ( "type" ) ;
57
56
const value = await element . getAttribute ( "value" ) ;
58
57
59
58
assert . equal ( tag , "input" ) ;
60
- assert . equal ( type , "radio " ) ;
61
- assert . equal ( value , "m " ) ;
59
+ assert . equal ( type , "checkbox " ) ;
60
+ assert . equal ( value , "1 " ) ;
62
61
await driver . quit ( ) ;
63
62
} ) ;
64
63
65
- it ( 'Check if element can be found by xpath' , async function ( ) {
64
+
65
+
66
+ it ( 'Check if element can be found by link text' , async function ( ) {
66
67
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
67
68
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
68
- const element = await driver . findElement ( By . xpath ( '//input[@name="newsletter"]' ) ) ;
69
+ const element = await driver . findElement ( By . linkText ( "Selenium Official Page" ) ) ;
69
70
70
71
const tag = await element . getTagName ( ) ;
71
- const type = await element . getAttribute ( "type" ) ;
72
- const value = await element . getAttribute ( "value" ) ;
72
+ const href = await element . getAttribute ( "href" ) ;
73
73
74
- assert . equal ( tag , "input" ) ;
75
- assert . equal ( type , "checkbox" ) ;
76
- assert . equal ( value , "1" ) ;
74
+ assert . equal ( tag , "a" ) ;
75
+ assert . equal ( href , "https://www.selenium.dev/" ) ;
77
76
await driver . quit ( ) ;
78
77
} ) ;
79
78
80
- it ( 'Check if element can be found by tag name ' , async function ( ) {
79
+ it ( 'Check if element can be found by partial link text ' , async function ( ) {
81
80
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
82
81
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
83
- const element = await driver . findElement ( By . tagName ( "h2 ") ) ;
82
+ const element = await driver . findElement ( By . partialLinkText ( "Official Page ") ) ;
84
83
85
84
const tag = await element . getTagName ( ) ;
86
- const text = await element . getText ( ) ;
85
+ const href = await element . getAttribute ( "href" ) ;
87
86
88
- assert . equal ( tag , "h2 " ) ;
89
- assert . equal ( text , "Contact Selenium " ) ;
87
+ assert . equal ( tag , "a " ) ;
88
+ assert . equal ( href , "https://www.selenium.dev/ " ) ;
90
89
await driver . quit ( ) ;
91
90
} ) ;
92
91
93
- it ( 'Check if element can be found by link text ' , async function ( ) {
92
+ it ( 'Check if element can be found by tag name ' , async function ( ) {
94
93
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
95
94
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
96
- const element = await driver . findElement ( By . linkText ( "Selenium Official Page ") ) ;
95
+ const element = await driver . findElement ( By . tagName ( "a ") ) ;
97
96
98
97
const tag = await element . getTagName ( ) ;
99
- const href = await element . getAttribute ( "href" ) ;
98
+ const text = await element . getText ( ) ;
100
99
101
100
assert . equal ( tag , "a" ) ;
102
- assert . equal ( href , "https://www.selenium.dev/ " ) ;
101
+ assert . equal ( text , "Selenium Official Page " ) ;
103
102
await driver . quit ( ) ;
104
103
} ) ;
105
104
106
- it ( 'Check if element can be found by partial link text ' , async function ( ) {
105
+ it ( 'Check if element can be found by xpath ' , async function ( ) {
107
106
let driver = await new Builder ( ) . forBrowser ( 'chrome' ) . build ( ) ;
108
107
await driver . get ( 'https://www.selenium.dev/selenium/web/locators_tests/locators.html' ) ;
109
- const element = await driver . findElement ( By . partialLinkText ( "Official Page" ) ) ;
108
+ const element = await driver . findElement ( By . xpath ( '//input[@value="f"]' ) ) ;
110
109
111
110
const tag = await element . getTagName ( ) ;
112
- const href = await element . getAttribute ( "href" ) ;
111
+ const type = await element . getAttribute ( "type" ) ;
112
+ const value = await element . getAttribute ( "value" ) ;
113
113
114
- assert . equal ( tag , "a" ) ;
115
- assert . equal ( href , "https://www.selenium.dev/" ) ;
114
+ assert . equal ( tag , "input" ) ;
115
+ assert . equal ( type , "radio" ) ;
116
+ assert . equal ( value , "f" ) ;
116
117
await driver . quit ( ) ;
117
118
} ) ;
118
119
} ) ;
0 commit comments