selenium--JS元素的操作
##################################################### ## JS元素操作 ##################################################### JS元素值输入: ele = b.find_element_by_xxxx() b.execute_script("arguments[0].value='admin';",ele) JS点击元素: ele = b.find_element_by_xxxx() b.execute_script('arguments[0].click()', ele) JS去除元素属性: ele = b.find_element_by_xxxx() b.execute_script('arguments[0].removeAttribute("readonly");', ele) ele.send_keys('test') JS处理滚动条: target = driver.find_element_by_xxxx() driver.execute_script("arguments[0].scrollIntoView();", target) b = webdriver.Chrome() b.implicitly_wait(30) b.get('file:///E:/ZM20190316/2.Selenium/TestDemo/uploadFileDemo/uploadFileDemo.html') b.maximize_window() ipt_value = b.find_element_by_id('f') b.execute_script('arguments[0].removeAttribute("readonly");', ipt_value) ipt_value.clear() ipt_value.send_keys('abcd') sleep(3) b.quit()