本文为霍格沃兹测试开发学社学员学习笔记分享
原文链接:https://ceshiren.com/t/topic/27336
def test_capability():
# 切换成 windows 就会报错
capabilities = {"browserName": "chrome", "platformName": "windows"}
# 通过 desired_capabilities 添加配置信息
driver = webdriver.Chrome(desired_capabilities=capabilities)
driver.implicitly_wait(5)
driver.get("https://ceshiren.com/")
# 输入框输入搜索内容[霍格沃兹测试学院]
text = driver.find_element(By.CSS_SELECTOR, ".login-button").text
# 点击搜索按钮
print(text)
time.sleep(3)
driver.quit()
def test_ceshiren2():
hogwarts_grid_url = "https://selenium-node.hogwarts.ceshiren.com/wd/hub"
capabilities = {"browserName":"chrome","browserVersion":"101.0"}
# 配置信息
# 实例化Remote,获取可以远程控制的driver实例对象
# 通过 command_executor 配置selenium hub地址
# 通过 desired_capabilities 添加配置信息
driver = webdriver.Remote(
command_executor=hogwarts_grid_url,
desired_capabilities=capabilities)
driver.implicitly_wait(5)
driver.get("https://ceshiren.com/")
# 输入框输入搜索内容[霍格沃兹测试学院]
text = driver.find_element(By.CSS_SELECTOR, ".login-button").text
# 点击搜索按钮
print(text)
time.sleep(3)
driver.quit()