gpt4 book ai didi

python - “WebElement”对象没有属性 'set_value'

转载 作者:行者123 更新时间:2023-12-01 04:54:10 29 4
gpt4 key购买 nike

我想使用appium在android应用程序的编辑框中设置一个值。我正在使用 python 脚本来自动化它。但我总是遇到一些错误。
我的 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)

每当我运行它时,我总是会收到错误:

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

最佳答案

要在 WebElement 中输入值,请使用 Selenium WebDriver 方法 send_keys:

element = self.driver.find_element_by_class_name('android.widget.EditText')
element.send_keys('qwerty')

请参阅Selenium Python Bindings documentation了解更多详情。

关于python - “WebElement”对象没有属性 'set_value',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27821776/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com