标签:quit style pat ade tail .com switch 接受 selenium
#coding=utf-8 from selenium import webdriver import time driver = webdriver.Firefox() driver.get("https://www.baidu.com/") #给搜索输入框标红javascript脚本 js="var q=document.getElementById(\"kw\");q.style.border=\"2px solid red\";" #调用给搜索输入框标红js脚本 driver.execute_script(js) time.sleep(3) #单独执行js脚本 driver.execute_script(‘alert("输入框标红了!")‘) time.sleep(3) #接受提示信息 driver.switch_to_alert().accept() time.sleep(3) #js隐藏元素,将获取的图片元素隐藏 img1 = driver.find_element_by_xpath("//*[@id=‘lg‘]/img") driver.execute_script(‘$(arguments[0]).fadeOut()‘,img1) time.sleep(3) driver.find_element_by_xpath("//*[@id=‘kw‘]").send_keys("selenium") driver.find_element_by_xpath("//*[@id=‘su‘]").click() time.sleep(3) driver.quit()
原文地址:https://blog.csdn.net/u013372487/article/details/46502853
精华 selenium_webdriver(python)调用js脚本
标签:quit style pat ade tail .com switch 接受 selenium
原文地址:https://www.cnblogs.com/zhangdingqu/p/9712375.html