Code Monkey home page Code Monkey logo

browserup-proxy-py's Introduction

browserup-proxy-py

Python client for the BrowserUp Proxy REST API.

How to install

  1. pip install git+https://github.com/browserup/browserup-proxy-py.git@master#egg=browserup-proxy==0.1.0
  2. Use bootstrap.sh to download browserup-proxy, selenium-server, chromedriver and geckodriver (Firefox)
  3. Add tools/chromedriver and tools/geckodriver to OS PATH. Example:
    cd /usr/local/bin
    ln -s ~/projects/browserup-proxy-py/tools/geckodriver geckodriver
    ln -s ~/projects/browserup-proxy-py/tools/chromedriver chromedriver
    

How to use with selenium-webdriver

pip install selenium

Manually:

from browserupproxy import Server
from selenium import webdriver

server = Server("tools/browserup-proxy-1.1.0/bin/browserup-proxy")
server.start()
proxy = server.create_proxy()

profile  = webdriver.FirefoxProfile()
profile.set_proxy(proxy.selenium_proxy())
driver = webdriver.Firefox(firefox_profile=profile)

proxy.new_har("google")
driver.get("http://www.google.co.uk")
proxy.har # returns a HAR JSON blob

server.stop()
driver.quit()

for Chrome use

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--proxy-server={0}".format(proxy.proxy))
browser = webdriver.Chrome(chrome_options = chrome_options)

Running Tests

git clone [email protected]:browserup/browserup-proxy-py.git
cd browserup-proxy-py
pyenv virtualenv 3.6.7 browserup-proxy-venv
pyenv activate browserup-proxy-venv
pip install -r requirements/base.txt
pip install -r requirements/dev.txt
./bootstrap.sh

Start a browserup instance:

./start-server.sh

In a separate window:

py.test

If you are going to watch the test, the 'human' ones should display an english muffin instead of the american flag on the 'pick your version' page. Or at least it does from Canada.

To run the tests in a CI environment, disable the ones that require human judgement by adding "-m "not human" test" to the py.test command.

py.test -m "not human" test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.