If you wanted to access the element that has the text "This element has an ID that changes every time the page is loaded" in it, then which of the following is used?

Options
- //div[contains(@id,'time_')]
- //div[contains(@id_time())]
- //div[parameter(@id_time())]
- //div[parameter(@id,’time_’)]


CORRECT ANSWER : //div[contains(@id,'time_')]

Discussion Board
Selenium

Answer: //div[contains(@id,'time_')]
Solution: In selenium there are 2 functions for searching element that contain text value in it.
starts-with() : //div[starts-with(@id,'time_')]
contains() : //div[contains(@id,'time_')]
Therefore, Option A is the correct answer.


Rohit Srivastava 07-28-2014 05:34 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement