使用python / selenium提取文本

时间:2015-11-05 13:03:26

标签: python selenium-webdriver

但已引用此网站多年。 我正在尝试提取文本“CRITICIAL”或此字段中可能包含的任何其他文本:

源代码:

<td id="x-auto-821" class="x-grid3-col x-grid3-cell x-grid3-td-severity " style="width:63px;" role="gridcell">
   <div class="x-grid3-cell-inner x-grid3-col-severity"    unselectable="off">CRITICAL</div>
</td>

我的代码:

try:
    severity = driver.find_element_by_xpath("//td[@id='x-auto-821']/div[@class='x-grid3-cell-inner x-grid3-col-severity']).text
except Exception as e:
    print("\nFAILED to get Severity because of %s\n" % e)

我得到例外:

FAILED to get Severity because of Message: Unable to locate element: {"method":"xpath","selector":"//td[@id='x-auto-821']/div[@class='x-grid3-cell-inner']"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmp_wNe_1/extensions/fxdriver@googlecode.com/components/driver-component.js:10271)
at FirefoxDriver.prototype.findElement (file:///tmp/tmp_wNe_1/extensions/fxdriver@googlecode.com/components/driver-component.js:10280)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmp_wNe_1/extensions/fxdriver@googlecode.com/components/command-processor.js:12274)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmp_wNe_1/extensions/fxdriver@googlecode.com/components/command-processor.js:12279)
at DelayedCommand.prototype.execute/< (file:///tmp/tmp_wNe_1/extensions/fxdriver@googlecode.com/components/command-processor.js:12221)

0 个答案:

没有答案