How to locate an element by Xpath with its dynamic title

Example: I have two images
some_date1 and some_date2 are generated dynamically.
How to locate them using CSS locator ?
click css=img[title*=’since’] : will not work because it won’t
make difference between the two images.

Here is the solution:
If you want to click on the first try this : //IMG[contains(@title,’Critical since’)][1]

3 thoughts on “How to locate an element by Xpath with its dynamic title

  1. Pavan Panguluri says:

    Identify the constant part of the XPath and use the Java Script contains() function to identify the element whose XPath chages dynamically.

  2. sphere says:

    Hi sir,

    How do I automate test if the Google analytics tagging below thru webdriver

    Example 1. ga Event : “[_trackEvent,engage,comment]”
    Example 2. GA evt:{“atlas”:”knscbs_ContactOfficeThankYouSubmit_1″,”GA_event”:{“category”:”engage”,”action”:”comment”},”GA_PageView”:”/property?action=siteComment”}

    Sir, I’m new with this and I hope you can help me on this.

    Thanks in advance


Leave a Reply

Your email address will not be published. Required fields are marked *