The API definitions in this chapter shows the absolute location of classes. However the recommended import style is as given below:

from selenium import webdriver

Then, you can access the classes like this:

webdriver.Firefox
webdriver.FirefoxProfile
webdriver.Chrome
webdriver.ChromeOptions
webdriver.Ie
webdriver.Opera
webdriver.PhantomJS
webdriver.Remote
webdriver.DesiredCapabilities
webdriver.ActionChains
webdriver.TouchActions
webdriver.Proxy

The special keys class (Keys) can be imported like this:

from selenium.webdriver.common.keys import Keys

The exception classes can be imported like this (Replace the TheNameOfTheExceptionClass with actual class name given below):

from selenium.common.exceptions import [TheNameOfTheExceptionClass]

Conventions used in the API

Some attributes are callable (or methods) and others are non-callable (properties). All the callable attributes are ending with round brackets.

Here is an example for property:

  • current_url

    URL of the current loaded page.

    Usage:

    driver.current_url
    

Here is an example for a method:

  • close()

    Closes the current window.

    Usage:

    driver.close()

相关文章:

  • 2022-02-25
  • 2021-09-14
  • 2021-07-27
  • 2021-08-23
  • 2021-12-06
  • 2021-06-07
  • 2021-08-03
  • 2021-04-07
猜你喜欢
  • 2021-07-05
  • 2021-11-19
  • 2022-01-03
  • 2022-02-14
  • 2022-01-28
  • 2021-12-08
  • 2021-08-16
相关资源
相似解决方案