
上QQ阅读APP看书,第一时间看更新
There's more...
Here is the full Selenium documentation: http://selenium-python.readthedocs.io/.
For each of the elements, there's extra information that can be extracted, such as .is_displayed() or .is_selected(). Text can be searched using .find_element_by_link_text() and .find_element_by_partial_link_text().
Sometimes, opening a browser can be inconvenient. An alternative is to start the browser in headless mode and manipulate it from there, like this:
>>> from selenium.webdriver.chrome.options import Options
>>> chrome_options = Options()
>>> chrome_options.add_argument("--headless")
>>> browser = webdriver.Chrome(chrome_options=chrome_options)
>>> browser.get('https://httpbin.org/forms/post')
The page won't be displayed. But a screenshot can be saved anyway with the following line:
>>> browser.save_screenshot('screenshot.png')