AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_id‘
AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'
·
最近在做测试的时候发现driver.find_element_by_id的源代码改了如下:
driver.find_element_by_id("j_username").send_keys("wanjiayang") # 填入用户名
driver.find_element_by_id("j_password").send_keys("19980618.wanjia") # 填入密码
继续使用会报错AttributeError: 'WebDriver' object has no attribute 'find_element_by_id'。
源码改为
def find_element(self, by=By.ID, value=None) -> WebElement: """ Find an element given a By strategy and locator. :Usage: :: element = driver.find_element(By.ID, 'foo') :rtype: WebElement """
这样就正常登录了
driver.find_element(By.ID, "j_username").send_keys("wanjiayang") # 填入用户名
driver.find_element(By.ID, "j_password").send_keys("19980618.wanjia") # 填入密码
更多推荐
所有评论(0)