Reputation: 11
I have written the below code to identify the element in chrome and click on it, but later I realized that value for "@id" (u_jsonp_X_x) is keep on changing and that's causing fail to identify the element.
dr2.findElement(By.xpath("//*[@id='u_jsonp_2_4']/div/a[3]/span[1]")).click();
To resolve this issue, I have used below code based on my understanding but still not working
dr2.findElement(By.xpath("[starts-with(@id=(),'u_jsonp_2')]")).click();
Could you please help me to resolve this issue?
Upvotes: 1
Views: 93
Reputation: 473873
The XPath syntax in the second case is not correct, you meant:
dr2.findElement(By.xpath("//*[starts-with(@id, 'u_jsonp')]/div/a[3]/span[1]")).click();
Upvotes: 2