Skip to main content

Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.

Project description

Selenium Requests

Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.

Before the actual request is made, a local HTTP server is started that serves a single request made by the webdriver instance to get the "standard" HTTP request headers sent by this webdriver; these are cached (only happens once during its lifetime) and later used in conjunction with the Requests library to make the requests look identical to those that would have been sent by the webdriver. Cookies held by the webdriver instance are added to the request headers and those returned in a response automatically set for the webdriver instance.

Features

  • Determines and sends the default HTTP headers (User-Agent etc.) for the chosen WebDriver
  • Manages cookies bidirectionally between requests and Selenium
  • Switches to already existing window handles or temporarily creates them to work with the webdriver's cookies when making a request
  • All operations preserve the original state of the WebDriver (active window handle and window handles)
  • Tested to work with Selenium (3.0.1) using Mozilla Firefox (49.0.2), Google Chrome (54.0.2840.71) and PhantomJS (2.1.1)

Usage

# Import any WebDriver class that you would usually import from
# selenium.webdriver from the seleniumrequests module
from seleniumrequests import Firefox

# Simple usage with built-in WebDrivers:
webdriver = Firefox()
response = webdriver.request('GET', 'https://www.google.com/')
print(response)


# More complex usage, using a WebDriver from another Selenium-related module:
from seleniumrequests.request import RequestMixin
from someothermodule import CustomWebDriver


class MyCustomWebDriver(RequestMixin, CustomWebDriver):
    pass


custom_webdriver = MyCustomWebDriver()
response = custom_webdriver.request('GET', 'https://www.google.com/')
print(response)

Installation

pip install selenium-requests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selenium-requests-1.3.3.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenium_requests-1.3.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file selenium-requests-1.3.3.tar.gz.

File metadata

  • Download URL: selenium-requests-1.3.3.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.13.13-arch1-1

File hashes

Hashes for selenium-requests-1.3.3.tar.gz
Algorithm Hash digest
SHA256 7d07f9b6d907465bd1c9f998205a7ada0d0f9831de92ed0a72f6b7218f3914cd
MD5 2fdfceeeed90d8c73a09a38136de5ec5
BLAKE2b-256 54c85c71c6f203d02304836cd383f4598dbe7e0b614a6173366be69d5b5c23a4

See more details on using hashes here.

File details

Details for the file selenium_requests-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: selenium_requests-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.9.6 Linux/5.13.13-arch1-1

File hashes

Hashes for selenium_requests-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 96b3bfe7109800a6e4f2c21ea8225401293b3d9de9811492e746b5ad213b3162
MD5 5b4071e2943282b735208a04b50a3d5d
BLAKE2b-256 231f40545adcc9d72f39a9dfed90fc18d64a659ada0abd8ca3162d935cdcdf67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page