File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 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 ' ) ;
22const { sprintf } = require ( 'sprintf-js' ) ;
33
44const { xpathLocator } = require ( './utils' ) ;
@@ -162,7 +162,7 @@ class Locator {
162162 */
163163 toXPath ( ) {
164164 if ( this . isXPath ( ) ) return this . value ;
165- if ( this . isCSS ( ) ) return cssToXPath ( this . value ) ;
165+ if ( this . isCSS ( ) ) return cssToXPath . convert ( this . value ) ;
166166
167167 throw new Error ( 'Can\'t be converted to XPath' ) ;
168168 }
Original file line number Diff line number Diff line change 8080 "chai-string" : " ^1.5.0" ,
8181 "chalk" : " 4.1.2" ,
8282 "commander" : " 11.0.0" ,
83+ "convert-cssxpath" : " 1.0.2" ,
8384 "cross-spawn" : " 7.0.3" ,
84- "css-to-xpath" : " 0.1.0" ,
8585 "envinfo" : " 7.11.0" ,
8686 "escape-string-regexp" : " 4.0.0" ,
8787 "figures" : " 3.2.0" ,
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ const xml = `<body>
4949 <input name="name1" label="Выберите услугу" type="text" value=""/>
5050 </div>
5151 </fieldset>
52- <label>Hello<a href="#">Please click</a></label>
52+ <label class="n-1" >Hello<a href="#">Please click</a></label>
5353 </div>
5454 <input type="hidden" name="return_url" value="" id="return_url" />
5555</body>` ;
@@ -205,6 +205,12 @@ describe('Locator', () => {
205205 } ) . to . throw ( 'round brackets' ) ;
206206 } ) ;
207207
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+
208214 it ( 'should throw an error when locator with specific position is nested' , ( ) => {
209215 expect ( ( ) => {
210216 Locator . build ( 'tr' ) . withChild ( Locator . build ( 'td' ) . first ( ) ) ;
You can’t perform that action at this time.
0 commit comments