execute_script python-selenium calls provided js operation

Automated programming elements encountered in positioning the drop-down box,

 

 

# With js selected affiliation 
self.driver.find_elements_by_xpath ( ' // div [2] / div / div / div / div / I ' ) [0] .click ()   # first click on the down button 
org = self.driver.find_element_by_xpath ( ' // div [2] / div / div / div [2] / UL [2] / Li [. 7] ' )   # positioning element to be selected, attention here is find_element 
# scrollIntoView Causes () is the DOM API part, need to run it WebElement but not WebElement (S) in the list, so you can not use find_elements 
self.driver.execute_script ( " arguments the [0] .scrollIntoView (); " , ORG)   # execute js, scroll down to the to positioning element position 
time.sleep (3)    # wait a few seconds to see whether the scroll bar to decline 
org.click ()      # clicks 

time.sleep (3)

 

Guess you like

Origin www.cnblogs.com/wenm1128/p/11534887.html