Python3 selenium, python3selenium
In fact, this is equivalent to simulating a person's Click Event to continuously access the browser. If you have played the glory of the king, there will be a bug in the January 2016 version.
After downloading a key genie from an Android phone, you can set buttons in adventure mode to enable the mobile phone to automatically go through the game. 19 gold coins in one game and a hero in one night. However
Programmers are not vegetarian either. A maximum of 4000 gold coins is set for a week. If you are interested, try it. (Note: The mobile phone requires root)
Enter the subject:
from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.support.wait import WebDriverWait
Download the selenium module before writing.
Brguge = webdriver. chrome () # declare the driver object try: brguge. get ('https: // www.baidu.com ') # Send the get request input = brguge. find_element_by_id ('kw ') # Find the target input. send_keys ('python') # input the python keyword input. send_keys (Keys. ENTER) # Press ENTER to ENTER wait = WebDriverWait (brguge, 10) # wait for the element to load out wait. until (EC. presence_of_element_located (. ID, 'content _ left') # Load print (brguge. current_url) # print (brguge. get_cookie () # output cookie print (brguge. page_source) # finally: brguge. close () # close Google Chrome
The basic usage of some selenium modules is as follows:
Search Element
Single element (from selenium import webdriver)
Brguge. find_element_by_id ('q') use this element to find the element whose id is q.
Brguge. find_element_by_css_selector ('# Q'). The css style is q.
Brguge. find_element_by_xpath ('// * [@ id = "q"]') has the same effect.
Brguge. find_element_by_name () is searched by name.
Brguge. find_element_by_link_text () is searched through link.
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
Brguge. find_element (By. ID, 'q') common search method
Multiple Elements (find_elements) are added with s
It is printed as a list.
Brguge. find_elements_by_css_selector ('. service-bd li') elements whose css style is li
Brguge.find_elements(By.css _ selector, '. service-bd li').
(Using indexes, you can obtain one or more elements)
Element interaction operation (get the element and give it another command)
Select the input box -- "send_keys ('input text') --" clear () clear the input box -- in the input field -- "find search --" click (click)
Input. clear () clear button
Interactive action (attach the action to the action chain for serial execution)
Switch_to_frame ('iframeresresult ')
Use the css style to find the two to interact
Call ActionChains (call Google's)
Drag_and_drop (source, target) first to second
Perform ()