File tree 3 files changed +10
-4
lines changed
3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
- const cssToXPath = require ( 'css-to-xpath ' ) ;
1
+ const cssToXPath = require ( 'convert-cssxpath ' ) ;
2
2
const { sprintf } = require ( 'sprintf-js' ) ;
3
3
4
4
const { xpathLocator } = require ( './utils' ) ;
@@ -162,7 +162,7 @@ class Locator {
162
162
*/
163
163
toXPath ( ) {
164
164
if ( this . isXPath ( ) ) return this . value ;
165
- if ( this . isCSS ( ) ) return cssToXPath ( this . value ) ;
165
+ if ( this . isCSS ( ) ) return cssToXPath . convert ( this . value ) ;
166
166
167
167
throw new Error ( 'Can\'t be converted to XPath' ) ;
168
168
}
Original file line number Diff line number Diff line change 80
80
"chai-string" : " ^1.5.0" ,
81
81
"chalk" : " 4.1.2" ,
82
82
"commander" : " 11.0.0" ,
83
+ "convert-cssxpath" : " 1.0.2" ,
83
84
"cross-spawn" : " 7.0.3" ,
84
- "css-to-xpath" : " 0.1.0" ,
85
85
"envinfo" : " 7.11.0" ,
86
86
"escape-string-regexp" : " 4.0.0" ,
87
87
"figures" : " 3.2.0" ,
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ const xml = `<body>
49
49
<input name="name1" label="Выберите услугу" type="text" value=""/>
50
50
</div>
51
51
</fieldset>
52
- <label>Hello<a href="#">Please click</a></label>
52
+ <label class="n-1" >Hello<a href="#">Please click</a></label>
53
53
</div>
54
54
<input type="hidden" name="return_url" value="" id="return_url" />
55
55
</body>` ;
@@ -205,6 +205,12 @@ describe('Locator', () => {
205
205
} ) . to . throw ( 'round brackets' ) ;
206
206
} ) ;
207
207
208
+ it ( 'should find element with class name contains hyphen' , ( ) => {
209
+ const l = Locator . build ( '' ) . find ( '.n-1' ) . first ( ) ;
210
+ const nodes = xpath . select ( l . toXPath ( ) , doc ) ;
211
+ expect ( nodes ) . to . have . length ( 1 , l . toXPath ( ) ) ;
212
+ } ) ;
213
+
208
214
it ( 'should throw an error when locator with specific position is nested' , ( ) => {
209
215
expect ( ( ) => {
210
216
Locator . build ( 'tr' ) . withChild ( Locator . build ( 'td' ) . first ( ) ) ;
You can’t perform that action at this time.
0 commit comments