Selenium Webdriver Interface

Source: Internet
Author: User

From selenium import webdriverfrom selenium.webdriver.common.keys import keysdriver = Webdriver. Firefox () driver.get ("http://www.python.org") assert "Python" in Driver.titleelem = Driver.find_element_by_name ("q") Elem.clear () Elem.send_keys ("Pycon") Elem.send_keys (Keys.return) assert "No results found." Not in driver.page_source# Driver.close () exit a sub-page
Driver.quit () Exit browser

A simple little chestnut.

One of the interesting input methods

For i In "SDSFA":    elem.send_keys ("Pycon")

Import unittestfrom Selenium import webdriverfrom selenium.webdriver.common.keys import Keysclass pythonorgsearch ( UnitTest. TestCase):    def setUp (self):        self.driver = Webdriver. Firefox ()    def test_search_in_python_org (self):        driver = self.driver        driver.get ("http://www.python.org ")        Self.assertin (" Python ", driver.title)        elem = Driver.find_element_by_name (" q ")        Elem.send_keys (" Pycon ")        Elem.send_keys (Keys.return)        assert" No results found. "Not in Driver.page_source    def tearDown ( Self):        self.driver.quit () if __name__ = = "__main__":    Unittest.main ()

  

Refer to the official documentation from Http://selenium-python.readthedocs.io/getting-started.html.

Selenium Webdriver Interface

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.