Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Cyber Security
  3. Question
Cyber Security

What does XPath test equals to?

Asked by Ankur Dwivedi Feb 23, 2022 481 views 1 answer
Share

About this question

 In Flipkart page, I searched for Apple ipads and clicked on first search result. Here, I wanted to click on 'BUY NOW'.


I used the following xpath and it worked:

//button[text()='BUY NOW']
Then I used the xpath with 'contains' but it didn't work:

//button[contains(text(),'BUY NOW')]

Also this:

//button[contains(text(),'BUY')]

But none worked. I was really surprised as to why 'contains' is not identifying the elements. I found the same behaviour with the 'Add to Cart' button as well.


Then I tried to identify another element - 'Wi-Fi+4G' with contains and it worked:

//a[contains(text(),'Wi-Fi+4G')]
//a[text()='Wi-Fi+4G']
Both the above xpath worked for me.

Explain why 'contains' is not working here?

Your answer

1 Answer

More Cyber Security discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Cyber Security Blogs

Guides, tips and career advice on Cyber Security from JanBask experts.