Detailed explanation of webdriverAPI interface of selenium

1. Browser Operation

driver.maximize_window() #Maximize the window 
driver.execute_script('window.scrollTo(0,0);') #Scroll the window to the top
driver.get_screenshot_as_file('jietu.png') #Intercept the current page

2. Get the label element

 

#Locate the target element by id 
driver.find_element_by_id('i1').send_keys('Mingyue out of Tianshan') #Locate the
target element by classname
driver.find_element_by_class_name('classname').send_keys('Vast sea of ​​clouds') #Pass
the name attribute Locate the target element
driver.find_element_by_name(name='name').send_keys('Changfeng tens of thousands of miles')
# Locate the target element through Xpath
driver.find_element_by_xpath('//*[@id="i1"]').send_keys ('Buidu Yumenguan')
# Locate the target element by css selector
driver.find_element_by_css_selector('.classname').send_keys('Hanxia Baidengdao') #Locate
by label name (in a page, the label will be repeated, so no need This is used to locate)
driver.find_element_by_tag_name('input')
# Find element by text in tag
driver.find_element_by_link_text('login') # Find driver
by fuzzy matching of text in tag .find_element_by_partial_link_text('登录')

 3. Shutdown and Exit

driver.close() #When more than one is opened, close the current page 
driver.quit() #Exit and close all pages

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324816588&siteId=291194637