我目前正在酱汁实验室进行一系列硒测试。我不想用所有Android浏览器进行测试,但我似乎无法弄清楚如何正确指定我想要一个Android设备。我已将此代码基于此模板:http://saucelabs.com/examples/example.py
我的代码:
browsers = [{"platform": "Linux",
"device-orientation" : "portrait",
"version": "4.4"},
{"platform": "Linux",
"device-orientation" : "portrait",
"deviceName" : "LG Nexus 4 Emulator",
"version": "4.4"},
{"platform": "Linux",
"device-orientation" : "portrait",
"deviceName" : "Samsung Galaxy S3 Emulator",
"version": "4.4"},
{"platform": "Linux",
"device-orientation" : "portrait",
"deviceName" : "Samsung Galaxy Nexus Emulator",
"version": "4.4"},
{"platform": "Linux",
"device-orientation" : "portrait",
"deviceName" : "Samsung Galaxy S4 Emulator",
"version": "4.4"}]
def on_platforms(platforms):
def decorator(base_class):
module = sys.modules[base_class.__module__].__dict__
for i, platform in enumerate(platforms):
d = dict(base_class.__dict__)
d['desired_capabilities'] = platform
name = "%s_%s" % (base_class.__name__, i + 1)
module[name] = new.classobj(name, (base_class,), d)
return decorator
@on_platforms(browsers)
class Mobile(unittest.TestCase):
def setUp(self):
self.desired_capabilities['name'] = self.id()
sauce_url = "http://%s:%s@ondemand.saucelabs.com:80/wd/hub"
self.driver = webdriver.Remote(
desired_capabilities=self.desired_capabilities,
command_executor=sauce_url % (USERNAME, ACCESS_KEY)
)
self.driver.implicitly_wait(30)
#self.driver.set_window_size(500,1000)
self.driver.get(test_site_url)
# selecting car insurance by click the checkbox (F1)
def test_f1_select_one_product_by_checkmark(self):
element_name = "//label[@for='bil']//span[1]"
productOption = self.driver.find_element_by_xpath(element_name)
productOption.click()
答案 0 :(得分:1)
启动Android会话所需的功能与您列出的功能略有不同。以下是一组适用于使用Selenium的Samsung Galaxy S4 Emulator会话的功能。
caps = {'browserName': "android"}
caps['platform'] = "Linux"
caps['version'] = "4.4"
caps['deviceName'] = "Samsung Galaxy S4 Emulator"
caps['deviceOrientation'] = "portrait"
可以在此处找到其他Android配置:
https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/