Reputation: 13
I want to select and click on the object present inside inner html (shown in the image). But the object is not getting identified. I am using Java.
Note --> my application not opening with any browser except Internet Explorer and I can't verify xpath from console/debugger so I have to verify it through code only.
Code I have tried so far but not working for me-->
driver.switchTo().frame("nav");
driver.findElement(By.xpath("//a href[@text='Administrate']")).click();
driver.switchTo().frame("nav");
driver.findElement(By.xpath("//a[@text='Administrate']")).click();
driver.findElement(By.xpath("/html/frameset/frame[1]/html/body/ul/li/ul/li[1]")).click();
Upvotes: 1
Views: 461
Reputation: 7708
You need to change your XPath like
driver.switchTo().frame("nav");
driver.findElement(By.xpath("//a[text()='Administrate system']")).click();
Note:- Here you need to pass complete string for better learning please refer Firepath to create and evaluate your xpath
Also can use contains
method to find an element on partial text basis
Upvotes: 0
Reputation: 50899
You are checking for exact text match, use contains
instead
driver.findElement(By.xpath("//a[contains(text(), 'Administrate')]")).click();
Or
driver.findElement(By.xpath("//a[contains(., 'Administrate')]")).click();
Please note the difference between text()
and @text
Upvotes: 1