Reputation: 357
Can you help me to select an object in Selenium Webdriver which xpath value is dynamical. The xpath is
dd.findElement(By.xpath("//*[@id='defaultSwatchContainer_wxnit']/div/div/ul/li[list]"))
Here "wxnit" after "defaultSwatchContainer_" changes with every page load. Thanks
Upvotes: 0
Views: 2090
Reputation: 1869
dd.findElement(By.xpath("//*[contains(@id,'defaultSwatchContainer_')]/div/div/ul/li[list]"))
Upvotes: 0
Reputation: 51473
You can use the xpath starts-with function
"//*[starts-with(@id, 'defaultSwatchContainer_')]/div/div/ul/li[list]"
Upvotes: 1