2-7 different ways to locate .py

webdriver the Selenium Import from 
Import Time
# import expected_conditions expected package to determine whether the correct title:
from selenium.webdriver.support Import expected_conditions AS EC
Driver = webdriver.Chrome ()
driver.maximize_window ()
driver.get ( "HTTP: //www.5itest .cn / the Register ")
# EC.title_is #title_is on behalf of current and anticipated title title is the same as
the time.sleep (5)
Print (EC.title_contains (" Register ")) #title_contains behalf as long as it contains the
# use id to locate e-mail address:
driver.find_element_by_id ( "register_email") send_keys ( "[email protected]").
# use the class to locate the user name, find_elements_by_class_name returns a list, the list can len, define the parent class, and then define subclasses:
user_name_element_node = driver.find_elements_by_class_name ( "Controls") [. 1]
user_element = user_name_element_node.find_element_by_class_name("form-control")
user_element.send_keys ( "dsads")
# password using the name anchor:
. driver.find_element_by_name ( "password") send_keys ( "990496256dd")
# xpath positioning using codes:
driver.find_element_by_xpath ( '// * [@ ID = "captcha_code "] '). send_keys (" 111111 ")

Guess you like

Origin www.cnblogs.com/zhang-da/p/12128826.html