当涉及到python或编码时,我还只是一个初学者。我正在尝试使用python-appium和页面对象模型来设置一个自动化框架。我的问题是,如何将setup方法包含到我的基页中?当我从我的测试脚本中调用这个方法时,它显示'driver‘is unresolved并抛出一个异常。我知道我只是错过了一些简单的东西,但是我的google-fu让我失败了,现在我在这里发布了。
下面是我的设置方法:
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0.1'
desired_caps['deviceName'] = '05157df532e5e40e'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(
os.path.join(os.path.dirname(__file__),
'/Users/tyler/Desktop/Instasize_20172109_3.9.9_118_google.apk'))
desired_caps['appPackage'] = 'com.jsdev.instasize'
desired_caps['appActivity'] = '.activities.MainActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub',
desired_caps)我想对我的所有测试或其变体调用此方法,具体取决于所使用的设备。下面是我试图从我的基本页面调用它的方式:
def driverSetup(self):
driverSetup = DriverBuilderAndroid(driver)
driverSetup.setUp()如果您还需要任何其他信息,请告诉我。如果您能参考python appium POM教程,也将不胜感激。这是我在stackoverflow上的第一篇文章。
发布于 2018-03-30 11:33:20
我使用上面所示的设置创建了一个名为driverBuilder的单独python文件。然后我将它导入到我的每个测试文件中,并像这样调用该方法:
from DriverBuilder import DriverBuilder """<--class from DriverBuilder file"""
def test(self):
driver = DriverBuilder.driver https://stackoverflow.com/questions/46506474
复制相似问题