简体   繁体   中英

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:

<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的元素。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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