gpt4 book ai didi

使用 selenium 在 Sauce Lab 上进行 Android 测试

转载 作者:行者123 更新时间:2023-11-30 02:31:27 26 4
gpt4 key购买 nike

我目前正在 sauce lab 上运行一系列 selenium 测试。我不会对所有 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()

最佳答案

启动 Android session 所需的功能与您列出的功能略有不同。下面是一组适用于使用 Selenium 的 Samsung Galaxy S4 模拟器 session 的功能。

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#/

关于使用 selenium 在 Sauce Lab 上进行 Android 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27273879/

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