Python ';dict';对象没有属性';驱动程序&x27;
我不熟悉web自动化和python,所以请理解我的问题对你们来说可能微不足道。我正在尝试使用Appium测试应用程序并按下屏幕上的按钮。使用我的最低知识,我在下面创建了一个测试用例,该测试用例就是为了这样做的,但是我得到一个错误“dict”对象没有属性“driver”Python ';dict';对象没有属性';驱动程序&x27;,python,mobile,automation,appium,Python,Mobile,Automation,Appium,我不熟悉web自动化和python,所以请理解我的问题对你们来说可能微不足道。我正在尝试使用Appium测试应用程序并按下屏幕上的按钮。使用我的最低知识,我在下面创建了一个测试用例,该测试用例就是为了这样做的,但是我得到一个错误“dict”对象没有属性“driver” from appium import webdriver import time def setUp(): self = dict( platformName = "Android",
from appium import webdriver
import time
def setUp():
self = dict(
platformName = "Android",
platformVersion = "10",
deviceName= "name",
app= "C:\\AppiumProjects\\app-debug.apk",
automationName= "UiAutomator2",
appActivity = ".activities.SplashScreenActivity",
appPackage = 'genericsurveyapp2',
noReset = True,
)
self.driver = webdriver.Remote('http://localhost:4723/wd/hub',self)
time.sleep(2)
time.sleep(2)
self.el = self.driver.find_element_by_id("idacceptButton")
time.sleep(2)
self.el.click
setUp()
我想你对自己命名的配置选项字典感到困惑。 在类中工作时,
self
允许您使用“点表示法”引用类的变量和方法。但是,使用字典“点表示法”可以访问字典类的变量和方法,而不是字典的内容
对于如何解决此问题,您基本上有3个选项:
self['driver']=webdriver.Remote('http://localhost:4723/wd/hub",我自己)
self['el']=self['driver']。通过id(“idacceptButton”)查找元素
self['el']。单击()
driver
和el
指定为函数本地上下文中的变量。如果您打算在安装后丢弃config、driver和page元素,这就是我要使用的解决方案driver=webdriver.Remote('http://localhost:4723/wd/hub",我自己)
el=驱动程序。通过id(“idacceptButton”)查找元素
el.单击()
self\u driver=..