这是一个非常基本的问题,但我无法在任何地方找到答案...如何在python下使用webdriver检索在文本字段中输入的文本?我尝试了几个 text而且text()都没有用.
>>> driver.get("http://en.wikipedia.org/wiki/Main_Page")
>>> el = driver.find_elements_by_xpath("//input[contains(@name, 'search')]")
>>> el
[<selenium.webdriver.remote.webelement.WebElement object at 0x10d15f6d0>]
>>> el[0].send_keys("orange") # this works
>>> el[0].text
''
>>> el[0].text()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
>>> el[0].get_text()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'WebElement' object has no attribute 'get_text'
Run Code Online (Sandbox Code Playgroud)
谢谢!
Kv.*_*mar 11
因为我一直只使用属性操作.它对我很好.使用下面的代码.哪些文本需要从输入中获取
Description=driver.find_element_by_xpath("//*[@id='id_description']")
Description.clear()
Description.send_keys("xxx")
Description.get_attribute("xxxx")
print Description
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7318 次 |
| 最近记录: |