[英]'WebElement' object has no attribute 'set_value'
I want to set a value in editbox of android app using appium. 我想使用appium在android app的editbox中设置一个值。 And I am using python script to automate it.
我正在使用python脚本将其自动化。 But I am always getting some errors.
但是我总是遇到一些错误。
My python script is 我的python脚本是
import os
import unittest
import time
from appium import webdriver
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
import uiautomator
import math
element = self.driver.find_element_by_class_name('android.widget.EditText')
element.set_value('qwerty')
element = self.driver.find_element_by_name("Let's get started!")
element.click()
time.sleep(5)
When ever I am running it, I am always getting an error: 每当我运行它时,总是会出现错误:
AttributeError: 'WebElement' object has no attribute 'set_value'
To type a value into a WebElement, use the Selenium WebDriver method send_keys
: 要将值键入WebElement,请使用Selenium WebDriver方法
send_keys
:
element = self.driver.find_element_by_class_name('android.widget.EditText')
element.send_keys('qwerty')
See the Selenium Python Bindings documentation for more details. 有关更多详细信息,请参见Selenium Python绑定文档 。
It's as simple as the error: The type element is, has no set_value(str) or setValue(str) method. 就像错误一样简单:type元素是,没有set_value(str)或setValue(str)方法。 Maybe you meant
也许你是说
.setText('qwerty')?
Because there is no setText method in a EditText widget: http://developer.android.com/reference/android/widget/EditText.html 由于EditText小部件中没有setText方法,因此: http : //developer.android.com/reference/android/widget/EditText.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.