js selenium execution codes pop Day03-3

# ! / Usr / bin / env Python 
# Coding: utf8 
# python2 
# execute js code 
from the Selenium Import webdriver
 from selenium.webdriver Import ActionChains   # crack the code when using slide can drag pictures 
from selenium.webdriver.common.by Import by   # according to find what manner, By.ID, By.CSS_SELECTOR 
from selenium.webdriver.common.keys Import keys   # keyboard operation 
from selenium.webdriver.support Import expected_conditions EC AS   # and together with the following WebDriverWait 
from selenium.webdriver.support.wait import WebDriverWait  # 等待页面加载某些元素
import time

driver = webdriver.Chrome(r'C:\Users\Administrator\Desktop\chromedriver.exe')
try:
    driver.implicitly_wait(10)
    driver.get('http://www.baidu.com/')
    driver.execute_script(
        '''
        alert("best")
        '''
    )
    time.sleep(10)
finally:
    driver.close()

Guess you like

Origin www.cnblogs.com/zxdhahaha/p/11128258.html