Verification text is present in a specific element.

When creating selenium tests using a tag #{selenium}, how do you use complex XPath locators? I have a few simpler examples that work, but I really would like each element to not have an id to make testing easier.

I tried the following options:

#{selenium 'Sitemap'}
... 
// These work:
assertTitle('Site Map')
verifyTextPresent('Site Map')
verifyTextPresent('Login')
verifyText('id=test', 'Login')
verifyText('//ul', 'Login')
verifyText('//ul[2]', 'Login')

// this one results in "Element //ul[@class=sitemap] not found"
verifyText('Login','//ul[@class=sitemap]')

#{/selenium}

Has anyone gotten more sophisticated versions? It looks like it should work according to selenium docs. Also, is there any creation of selenium tests in the Play context, documented anywhere? The only mention I can find of these are trivial examples .

+2
source share
2 answers

You tried

//ul[@class='sitemap']

Sitemap. XPath , id, .

+4

. xpaths, DOM, , xpaths ( IE, JavaScript).

, xpath ID DOM, , , DOM, xpath, , DOM, .

, xpaths, http://www.lazeryattack.com . - , , , , :

  • ://ul[@id='leftMenu']/li/a[.='Voice Comms ']
  • H3, span " "://div[@id='news']/h3[span[.=' '] ]
  • ://div[@id='news']/h3[span[.=' ]]/:: [1]
  • ://div[@id='news']/h3[span[.=' ]]/-:: [2]
  • div div featuredNews h2 "New Look And Feel"://div [@id = 'featuredNews']/descendant:: h2 [. = " ".

FireFox FireBug FirePath, xpaths, .

+8

All Articles