Python3 Selenium Use

Source: Internet
Author: User

In fact, this is equivalent to the simulation of human click events to continuously access the browser. If you've ever played the glory of kings, there's a bug in the January 2016 version.

Android Phone Download a key wizard can set the button in adventure mode, let the phone automatically play the barrier, a game of 19 gold, one night on a hero. But

Programmers are not vegetarian. A limit of about 4000 coins was set for one weeks. If you are interested, you can try it. (Note: The phone needs root)

Go to the Chase:

 from Import Webdriver  from Import  by  from Import Keys  from Import Expected_conditions as EC  from Import Webdriverwait

Download the Selenium module before you write

Brguge=webdriver. Chrome ()#declaring a Driven objectTry: Brguge.get ('https://www.baidu.com')#send a GET requestINPUT=BRGUGE.FIND_ELEMENT_BY_ID ('kw')#Find the targetInput.send_keys ('python')#Enter the Python keywordInput.send_keys (Keys.enter)#EnterWait=webdriverwait (brguge,10)#wait for the element to load outWait.until (ec.presence_of_element_located (By.id,'Content_left'))#Loading    Print(Brguge.current_url)#path to output search    Print(Brguge.get_cookie ())#Output Cookie    Print(Brguge.page_source)#output result source codefinally: Brguge.close ()#Close Google Chrome

Here are some basic uses of some selenium modules

Find element
Single element (from selenium import Webdriver)
brguge.find_element_by_id (' Q ') use this element to find the element ID is Q
Brguge.find_element_by_css_selector (' #q ') to find the CSS style is Q
Brguge.find_element_by_xpath ('//*[@id = "q"] ') three effects
Brguge.find_element_by_name () to find by name
Brguge.find_element_by_link_text () through link to find
Brguge.find_element_by_partial_link_text ()
Brguge.find_element_by_tag_name ()
Brguge.find_element_by_class_name () Search by class

From selenium import Webdriver
From selenium.webdriver.common.by Import by
Brguge.find_element (by.id, ' Q ') General search method
Multiple elements (find_elements) plus a s
He's going to print it out in the form of a list
Brguge.find_elements_by_css_selector ('. service-bd li ') CSS style is an element of Li
Brguge.find_elements (By.css_selector, '. service-bd li ') two functions like
(You can get single or multiple elements with an index)

Element interaction (Gets the element and then gives him instructions)
Select Input Box--"Send_keys (' input text ')--" clear () empty input box--Find search in other--"click"
Input.clear () empty button
Interactive action (serial execution with an action attached to the action chain)
Switch_to_frame (' Iframeresult ')
Use CSS styles to find two to interact with each other
Call Actionchains (call Google's)
Drag_and_drop (Source,target) first to the second top
Perform ()

Python3 Selenium Use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.