I tried to find the link on a page to click:
<a id="folder0" class="js-folder icon-wrap icon-wrap_left menu__item__link menu__item__link_act menu__item__link_unread" href="/messages/inbox" rel="history">
<span class="js-folder-b-unread js-folder-unread menu__item__link__qnt">7</span>
<i class="js-folder-ico icon icon_left icon_folders icon_inbox_act"></i>
<span class="menu__item__link__text menu__item__link__text_linear">Input</span>
</a>
Java code:
driver.findElement(By.xpath(".//*[@id='folder0']/span[2]")).click();
But the driver can't locate the element:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='folder0']/span[2]"}
Thank you for all answers. I found solution to my problem. The last command was command which was linked with IFrame
WebElement editorFrame = driver.findElement(By.cssSelector("#sentmsgcomposeEditor_ifr"));
driver.switchTo().frame(editorFrame);
WebElement body1 = driver.findElement(By.tagName("body"));
body1.sendKeys(Keys.CONTROL + "a");
So i was in IFrame actually because of it i couldn't find any element. I performed following command:
driver.switchTo().defaultContent();
After that it is possible to find locators.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With