简体   繁体   English

Selenium html webdriver无法定位元素

[英]Selenium html webdriver Unable to locate element

I tried looking around for this error, but most of the time the problem was spelling errors, and I triple checked my spelling. 我试着四处寻找这个错误,但大多数时候问题是拼写错误,我三次检查我的拼写。 So here is the problem. 所以这就是问题所在。 I want to navigate around a website. 我想浏览一个网站。 I have this as my code: 我有这个作为我的代码:

WebDriver driver = new HtmlUnitDriver();
driver.get("http://genome.ucsc.edu/cgi-bin/hgTables");
WebElement element = driver.findElement(By.name("hgta_doFilterPage"));
element.submit();
WebElement filter = driver.findElement(By.name("hgta_fil.v.hg19.refGene.name.pat"));
filter.sendKeys("");

I am trying to go to the website listed, go down to the 'filter' page section, click create and then enter some values on the next page in the 'name' section and then submit again. 我正在尝试访问列出的网站,转到“过滤器”页面部分,单击“创建”,然后在“名称”部分的下一页上输入一些值,然后再次提交。 But I am getting this error: 但是我收到了这个错误:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element with name: hgta_fil.v.hg19.refGene.name.pat
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.37.1', revision: 'a7c61cbd68657e133ae96672cf995890bad2ee42', time: '2013-10-21 09:08:07'
System info: host: 'OSXLAP00693.local', ip: '192.168.2.9', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.7.0_25'

I double checked the naming on the page: view-source:http://genome.ucsc.edu/cgi-bin/hgTables and found: 我仔细检查了页面上的命名: view-source:http://genome.ucsc.edu/cgi-bin/hgTables并找到:

<TR VALIGN=BOTTOM align='left'><TD colspan=2> name </TD><TD>
<SELECT NAME='hgta_fil.v.hg19.knownGene.name.dd' class='normalText' style='width: 76px' >
<OPTION SELECTED>does</OPTION>
<OPTION>doesn't</OPTION>
</SELECT>
</TD><TD>match </TD><TD>
<INPUT TYPE=TEXT class='inputBox' NAME="hgta_fil.v.hg19.knownGene.name.pat" style='width: 140px' VALUE="*">
&nbsp; </TD></TR>
<TR VALIGN=BOTTOM align='left'><TD colspan=2> chrom </TD><TD>
<SELECT NAME='hgta_fil.v.hg19.knownGene.chrom.dd' class='normalText' style='width: 76px' ><!-- Here -->
<OPTION SELECTED>does</OPTION>
<OPTION>doesn't</OPTION>
</SELECT>
</TD><TD>match </TD><TD>

I am wondering if I am having this problem because the web driver is no longer pointing at the correct site? 我想知道我是否遇到此问题,因为网络驱动程序不再指向正确的网站?

源中的输入框的名称为hgta_fil.v.hg19.knownGene.name.pat ,但您正在搜索名为hgta_fil.v.hg19.refGene.name.pat的元素。

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

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