Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
SeleniumWebDriver:如何在包含属性的表中的元素上使用getText_Selenium_Xpath_Selenium Webdriver - Fatal编程技术网

SeleniumWebDriver:如何在包含属性的表中的元素上使用getText

SeleniumWebDriver:如何在包含属性的表中的元素上使用getText,selenium,xpath,selenium-webdriver,Selenium,Xpath,Selenium Webdriver,我在页面中有一个表,下面的xpath定位元素: .//*[@id='ctools-export-ui-list-items']/tbody/tr[16]/td[4] 该页面包含以下html: <table id="ctools-export-ui-list-items" class="sticky-enabled tableheader-processed sticky-table"> <thead> <tbody> <tr id="blah" cla

我在页面中有一个表,下面的xpath定位元素:

.//*[@id='ctools-export-ui-list-items']/tbody/tr[16]/td[4]
该页面包含以下html:

<table id="ctools-export-ui-list-items" class="sticky-enabled tableheader-processed sticky-table">
<thead>
<tbody>
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="blah" class="blah">
<tr id="RowInterestedIn" class="blah">
<td class="blah" title="blah">blah</td>
<td class="blah" title="blah">blah</td>
<td class="blah" title="blah">*/15 * * * *</td>
<td class="ctools-export-ui-start-time" title="Launched in thread 1 by anonymous (0)">2017-05-16 10:00:03</td>
<td class="blah" title="blah" title="no info">
<img typeof="foaf:Image" src="blah" alt=""/>
</td>
<td class="blah">Default</td>
<td class="blah">
</tr>

废话
废话
*/15 * * * *
2017-05-16 10:00:03
违约
但是,当我尝试使用定位器末尾的getText()获取文本时,返回一个空白。然而,我们可以清楚地看到,这本书中有文字:2017-05-16 10:00:03


感谢您的建议。

尝试此
xpath
//表[@id='ctools-export-ui-list-items']/tbody/tr/td[@class='ctools-export-ui-start-time']
,然后使用
getText()
检索文本
2017-05-16 10:00:03


让我知道这是否对您有帮助。

试试这个
xpath
//表[@id='ctools-export-ui-list-items']/tbody/tr/td[@class='ctools-export-ui-start-time']
,然后使用
getText()
检索文本
2017-05-16 10:00:03


如果这对您有帮助,请告诉我。

好的,我尝试在xpath末尾使用以下::text(),因为这样可以在firepath中找到文本。然而,这导致了一个错误;存在错误,但已按预期关闭

幸运的是,我的一位同事遇到了这个问题,我需要在原始xpath上使用getAttribute(“innerHTML”),而不是getText()


希望这对其他人有所帮助。

好的,我尝试在xpath的末尾使用以下::text(),因为这样可以在firepath中找到文本。然而,这导致了一个错误;存在错误,但已按预期关闭

幸运的是,我的一位同事遇到了这个问题,我需要在原始xpath上使用getAttribute(“innerHTML”),而不是getText()


希望这能帮助其他人。

没有使用我提供的xpath检索所需的文本吗?谢谢不,get文本返回的是空白。我通常会用这个。所以我认为这是我的选择。但是我们的两个XPath选择了相同的东西。经过进一步调查,末尾的following::text()选择了firepath中的文本,但这导致webdriver中出现错误。在实际检索文本之前,它需要getAttribute(“innerHTML”)。有一个“innerText”也可能在这种类型的实例中使用。那么您是否愿意与我们分享
getText
innerHTML
&
innerText
之间的区别?感谢您在没有阅读文档的情况下不确定,但在遇到困难时使用它和其他方法。这部分规范也会有所帮助:难道没有使用我提供的xpath检索所需的文本吗?谢谢不,get文本返回的是空白。我通常会用这个。所以我认为这是我的选择。但是我们的两个XPath选择了相同的东西。经过进一步调查,末尾的following::text()选择了firepath中的文本,但这导致webdriver中出现错误。在实际检索文本之前,它需要getAttribute(“innerHTML”)。有一个“innerText”也可能在这种类型的实例中使用。那么您是否愿意与我们分享
getText
innerHTML
&
innerText
之间的区别?感谢您在没有阅读文档的情况下不确定,但在遇到困难时使用它和其他方法。此外,本部分规范将有助于: