@@ -52,6 +52,19 @@ const xml = `<body>
5252 <label class="n-1">Hello<a href="#">Please click</a></label>
5353 </div>
5454 <input type="hidden" name="return_url" value="" id="return_url" />
55+
56+ <div class="ps-submenu-root">
57+ <ul class="ps-submenu-root">
58+ <li class="ps-menu-button">Adhemar da Silva</li>
59+ <li class="ps-menu-button">HelloWorld</li>
60+ <li class="ps-menu-button">Hallo</li>
61+ </ul>
62+ <ul class="ps-submenu-root">
63+ <li class="ps-menu-button">Adhemar da Silva</li>
64+ <li class="ps-menu-button">HelloWorld</li>
65+ <li class="ps-menu-button">Authoring</li>
66+ </ul>
67+ </div>
5568</body>` ;
5669
5770describe ( 'Locator' , ( ) => {
@@ -272,4 +285,14 @@ describe('Locator', () => {
272285 expect ( nodes [ 0 ] . firstChild . data ) . to . eql ( 'Sign In' , l . toXPath ( ) ) ;
273286 Locator . filters = [ ] ;
274287 } ) ;
288+
289+ it ( 'should be able to locate complicated locator' , ( ) => {
290+ const l = Locator . build ( '.ps-menu-button' )
291+ . withText ( 'Authoring' )
292+ . inside ( '.ps-submenu-root:nth-child(2)' ) ;
293+
294+ const nodes = xpath . select ( l . toXPath ( ) , doc ) ;
295+ expect ( nodes ) . to . have . length ( 1 , l . toXPath ( ) ) ;
296+ expect ( nodes [ 0 ] . firstChild . data ) . to . eql ( 'Authoring' , l . toXPath ( ) ) ;
297+ } ) ;
275298} ) ;
0 commit comments