Select checkbox in WebTable whose ID changes Dynamically

I need to select a check box  in a web table whose ID keeps changing dynamically.

XPath  – .//*[@id=’ht_29ad853cf427c8fd’]/div[2]/div/div/div/table/thead/tr/th[1]

next time the ID of the table is

XPath –  .//*[@id=’ht_e67040a19393993a’]/div[2]/div/div/div/table/thead/tr/th[1]

Please suggest

SD Train Asked on November 4, 2015 in Selenium WebDriver.
Add Comment
3 Answer(s)

You use this


XPath –  .//*[starts-with(@id, ‘ht_’]/div[2]/div/div/div/table/thead/tr/th[1]

Virender Singh Professor Answered on November 4, 2015.

Is there a way to extract id ‘ht_29ad853cf427c8fd’ from the previous div tag??

on February 18, 2016.
Add Comment

This does not work I am getting Invalid XPATH

.//input[starts-with(@id, ‘ht_’)]/div[1]/div/div/div/table/tbody/tr[1]/td[1]

Tried this also… 

SD Train Answered on November 5, 2015.
Add Comment

Use this>>

.//*[starts-with(@id, ‘ht_’)]/div[2]/div/div/div/table/thead/tr/th[1]

   ) was missing from Virender Singh  answer.

Shubham89 Train Answered on November 12, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.