Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在SeleniumWebDriver中获取web表值_Java_Selenium Webdriver - Fatal编程技术网

Java 如何在SeleniumWebDriver中获取web表值

Java 如何在SeleniumWebDriver中获取web表值,java,selenium-webdriver,Java,Selenium Webdriver,在SeleniumWebDriver中,从web表获取列值时,我面临一些问题。请让我知道如何获取值 HTML: <table id="ext-gen1916" class="x-grid-table x-grid-table-resizer x-unselectable" cellspacing="0" cellpadding="0" border="0" style="width: 4569px; -moz-user-select: none;"><tbody> &

在SeleniumWebDriver中,从web表获取列值时,我面临一些问题。请让我知道如何获取值

HTML

<table id="ext-gen1916" class="x-grid-table x-grid-table-resizer x-unselectable" cellspacing="0" cellpadding="0" border="0" style="width: 4569px; -moz-user-select: none;"><tbody>
  <tr>
    <tr class="x-grid-row x-grid-row-selected x-grid-row-focused x-grid-row-over">
    <td class=" x-grid-cell x-grid-cell-gridcolumn-1157 x-grid-clean-cell x-grid-cell-special x-grid-cell-first">
    <td id="ext-gen1949" class=" x-grid-cell x-grid-cell-actioncolumntext-1115 x-grid-clean-cell x-action-col-cell ">
    <td id="ext-gen1943" class=" x-grid-cell x-grid-cell-gridcolumn-1126 x-grid-clean-cell ">
    <td id="ext-gen1944" class=" x-grid-cell x-grid-cell-gridcolumn-1127 x-grid-clean-cell ">
    <td id="ext-gen1917" class=" x-grid-cell x-grid-cell-gridcolumn-1128 x-grid-clean-cell ">
        <div id="ext-gen1918" class="x-grid-cell-inner x-unselectable" style="; text-align: left;" unselectable="on">FP</div>
    </td>

尝试使用更具体的选择器:

ele=driver.findElement(By.xpath("//td/div[starts-with(@id, 'ext-gen') and @class='x-grid-cell-inner x-unselectable']")); 
还要检查
表是否位于
iframe
内。在这种情况下,您需要在“搜索”元素之前切换到
iframe

driver.switchTo().frame("Frame_ID");

多一点源代码将有助于理解这个问题。让我们看看你做了什么,有什么问题?共享您的代码以及问题描述、异常log@Andersson我试过这个,ele=driver.findElement(By.xpath(“//td[15]/div”);ele.getText();System.out.println(ele.getText());@Andersson,所有td的id名称都以“ext gen”开头,类也相同,并且每个
td
都有子
div
?您是否得到了错误的值,或者没有引发任何异常?是的,每个td都有子分区,是否可以共享页面
URL
“(//td/div[以(@id,'ext gen')和@class='x-grid-cell-internal x-unselectable']开头])[5]”
有效吗?
driver.switchTo().frame("Frame_ID");