Don't want to work overtime tonight, so hurry back to see the book:
1. Under the Selenium gadget: Firebug/firepath.
2. Determined the reading order, I think the difficulty starts relatively good, so I still first look at the Python-based selenium, another book to see, think of their ability or too weak, or from the friendly first, although before also saw some of the usage of by_id, but really actually do the weak chicken one.
3. Learned the Selenium keyboard event simulation, in fact, before this has been open for a long time the virtual machine opened once. I can't even remember the man, my heart is very tired.
Let's go back to the point and learn something and say it. Or the API that calls the keyboard, I'm going to say it first.
Send_keys (keys.back_space) Delete key
In the middle of a sentence, today the size of my gray head vinegar, changed several times the script to run up.
Send_keys (keys.space) space key
Send_keys (keys.tab) Tab key
Send_keys (keys.espace) fallback key
Send_keys (keys.enter) Enter
Send_keys (Keys.control, ' a ') Select all
Send_keys (Keys.control, ' C ') copy
Send_keys(Keys.control, ' x ') cut
Send_keys (Keys.control, ' V ') paste
Send_keys (KEYS.F1) F1
Personally think the keyboard event is quite practical, if you are familiar with the keyboard operation, you can do a lot of things, very convenient, the following is my code, basically the above are used again.
- From Selenium import Webdriver
- From Selenium.webdriver.common.action_chains import actionchains
- From Selenium.webdriver.common.keys import keys
- Driver=webdriver. Firefox ()
- Driver.get ("http://www.baidu.com")
- driver.find_element_by_id ("kw"). Send_keys ("seleniumm")
- driver.find_element_by_id ("kw"). Send_keys (Keys.back_space)
- driver.find_element_by_id ("kw"). Send_keys (Keys.space)
- driver.find_element_by_id ("kw"). Send_keys ("tutorial")
- driver.find_element_by_id ("kw"). Send_keys (Keys.control,' a ')
- driver.find_element_by_id ("kw"). Send_keys (Keys.control,' x ')
- driver.find_element_by_id ("kw"). Send_keys (Keys.control,' V ')
- driver.find_element_by_id ("kw"). Send_keys (Keys.enter)
Selenium Basic Keyboard method