如果在定位元素属性中包含了如ID等元素属性,那么在一个测试中,定位方法具体有哪几种,可以参考by模块中的By类,By的代码如下:
class By(object): """ Set of supported locator strategies. """ ID = "id" XPATH = "xpath" LINK_TEXT = "link text" PARTIAL_LINK_TEXT = "partial link text" NAME = "name" TAG_NAME = "tag name" CLASS_NAME = "class name" CSS_SELECTOR = "css selector" 具体用法如下:可以灵活的使用定位方法 from selenium.webdriver.common.by import By browser.find_element(By.ID,"kw").send_keys("selenium")
原文地址:https://www.cnblogs.com/qixc/p/11792003.html
时间: 2024-09-30 02:27:46