Elements interact Day03-1

# ! / Usr / bin / Python the env 
# Coding: UTF8 
# python2 
# Selenium remaining part 
# element interactions: 
# 1. Click apparent 
# 2.actions Change 
# 3. execute js code 
# 4.frame switch 

# The following elements are interaction 
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   # to find in what way, By.ID, By.CSS_SELECTOR 
from the Selenium .webdriver.common.keys ImportKeys   # keyboard operation 
from selenium.webdriver.support Import expected_conditions EC AS   # and together with the following WebDriverWait 
from selenium.webdriver.support.wait Import WebDriverWait   # Wait for page load certain elements 
Import Time 
Driver = webdriver.Chrome (R & lt ' C : \ the Users \ Administrator \ Desktop \ chromedriver.exe ' )
 the try : 
    driver.implicitly_wait ( 10 ) 
    driver.get ( ' http://www.jd.com/ ' ) 
    the time.sleep ( 5 ) 

    # clicks, Clear
    driver.find_element_by_id = INPUT ( ' Key ' ) 
    input.send_keys ( ' Biancheng ' ) 

    # lookup search button by class 
    Search driver.find_element_by_class_name = ( ' Button ' ) 
    search.click () 

    the time.sleep ( . 3 ) 

    INPUT2 = driver.find_element_by_id ( ' Key ' ) 
    input2.clear () 

    the time.sleep ( . 1 ) 

    input2.send_keys ( ' genius left ' ) 
    input2.send_keys (Keys.ENTER) 

    the time.sleep ( 10)
finally:
    driver.close()

 

Guess you like

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