使用Selenium(Python)获取输入框的值 [英] Get value of an input box using Selenium (Python)

查看:999
本文介绍了使用Selenium(Python)获取输入框的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在输入框中提取文本,

I am trying to extract the text in an input box,

<input type="text" name="inputbox" value="name" class="box">

我从

input = driver.find_element_by_name("inputbox")

我尝试了input.getText()但我得到了

I tried input.getText() but I got

AttributeError: 'WebElement' object has no attribute 'getText'

推荐答案

使用它来获取输入元素的值:

Use this to get the value of the input element:

input.get_attribute('value')

这篇关于使用Selenium(Python)获取输入框的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆