简体   繁体   English

我尝试了所有可能的方法使用Webdriver来定位元素,但收到错误消息“无法定位元素”

[英]I have tried all possible ways to locate an element using Webdriver, but getting an error “Unable to locate Element”

I am new to Automation, and trying to automate a website. 我是自动化的新手,正在尝试自动化网站。 I was able to login to the site using webdriver, however I am unable to locate any elements on the next page. 我可以使用webdriver登录到该站点,但是无法在下一页上找到任何元素。

I have tried locating it by id, name, css selector, linktext, xpath etc. I even put an explicit wait but that was of no help either. 我试图通过id,名称,css选择器,linktext,xpath等来定位它。我什至放了一个明确的等待,但这也没有帮助。

I get the following error every time I try to locate the element: 每次尝试查找元素时,都会出现以下错误:

Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"link text","selector":"Owner to Channel "} 由以下原因引起:org.openqa.selenium.NoSuchElementException:否这样的元素:无法找到元素:{“ method”:“ link text”,“ selector”:“ Channel的所有者”}

Here is the page source detail for the above mentioned button: 这是上述按钮的页面源详细信息:

Page source for the button 按钮的页面来源

在此处输入图片说明

Code to locate the button: 查找按钮的代码:

WebElement el = driver.findElement(By.linkText("Owner to Channel "));
el.click();

Any suggestions? 有什么建议么? May be I am missing something. 可能是我缺少了一些东西。

Thank you all for your suggestions. 谢谢大家的建议。

I found that there was a frame in the page source, but it didn't have an id or name. 我发现页面源中有一个框架,但是没有ID或名称。

By hit and trial, I tried switching to the frame with id 0, and it worked! 通过命中和尝试,我尝试切换到ID为0的框架,并且成功了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM