元素定位方法没错,但运行就是报错,如何解决
作者:互联网
-----》点击元素不生效,解决方法:用js脚本的方式点击元素
def js_click(self,locator): # js 脚本的单击,需要设置等待时间 time.sleep(5) ele = self.driver.find_element(*locator) js_code = """arguments[0].click();""" self.driver.execute_script(js_code, ele) def js_sendkeys(self,locator,value): #js脚本的发送,value=要发送的值 time.sleep(5) ele = self.driver.find_element(*locator) js_code = f"""arguments[0].value={value}""" self.driver.execute_script(js_code,ele)
标签:定位,code,self,driver,js,locator,报错,没错,ele 来源: https://www.cnblogs.com/mengmengxiyu/p/15094542.html