html - How to find the xpath of a header title in Selenium Webdriver with Java -


i need xpath of header title provides class , text within 'inspect element' tab.

the goal have if statement check see if title of page matches intended header can run code command selenium. reason why don't use "find web elements linktext" because actual content of header viewable in various pages. therefor, code run since text present. cannot use class since class name same every page.

i need header using both class name , text.

i have tried if(driver.findelements(by.xpath("//*[@class='classname' , contains (text(),'headertext')]")) !=null) if header text doesn't match continue run. believe because technically class present text although different elements.

two possible points there:

  1. driver.findelements(..) never null. return empty collection if no matching elements found. so, use driver.findelements(..).isempty() handle case when nothing found
  2. try using contains(.,'headertext') instead of contains(text(),'headertext') if still no elements found. first option work when header text element contains child tags / formatting tags.

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -