All Projects → umihico → pythonista-chromeless

umihico / pythonista-chromeless

Licence: MIT license
Serverless selenium which dynamically execute any given code.

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to pythonista-chromeless

Chromeless
🖥 Chrome automation made simple. Runs locally or headless on AWS Lambda.
Stars: ✭ 13,254 (+42654.84%)
Mutual labels:  integration-testing, headless, headless-chrome
Cuprite
Headless Chrome/Chromium driver for Capybara
Stars: ✭ 743 (+2296.77%)
Mutual labels:  integration-testing, headless, headless-chrome
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (+222.58%)
Mutual labels:  unit-testing, integration-testing
Automation Arsenal
Curated list of popular Java and Kotlin frameworks, libraries and tools related to software testing, quality assurance and adjacent processes automation.
Stars: ✭ 105 (+238.71%)
Mutual labels:  unit-testing, integration-testing
Android Client
An android client for the MifosX platform
Stars: ✭ 150 (+383.87%)
Mutual labels:  unit-testing, integration-testing
Aspnetcore Tests Sample
A project to help demonstrate how to do unit, integration and acceptance tests with an web api project using ASP.NET Core and Angular 7 front end.
Stars: ✭ 40 (+29.03%)
Mutual labels:  unit-testing, integration-testing
Redux Saga Test Plan
Test Redux Saga with an easy plan.
Stars: ✭ 1,135 (+3561.29%)
Mutual labels:  unit-testing, integration-testing
Dockertest
Write better integration tests! Dockertest helps you boot up ephermal docker images for your Go tests with minimal work.
Stars: ✭ 2,254 (+7170.97%)
Mutual labels:  unit-testing, integration-testing
Codeception
Full-stack testing PHP framework
Stars: ✭ 4,401 (+14096.77%)
Mutual labels:  unit-testing, integration-testing
Dntframeworkcore
Lightweight and Extensible Infrastructure for Building Web Applications - Web Application Framework
Stars: ✭ 208 (+570.97%)
Mutual labels:  unit-testing, integration-testing
Onion Architecture Asp.net Core
WhiteApp API solution template which is built on Onion Architecture with all essential feature using .NET 5!
Stars: ✭ 196 (+532.26%)
Mutual labels:  unit-testing, integration-testing
capybara-chrome
Chrome driver for Capybara using Chrome's remote debugging protocol
Stars: ✭ 27 (-12.9%)
Mutual labels:  headless, headless-chrome
Quixote
CSS unit and integration testing
Stars: ✭ 788 (+2441.94%)
Mutual labels:  unit-testing, integration-testing
Chromedp
A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.
Stars: ✭ 7,057 (+22664.52%)
Mutual labels:  unit-testing, headless
Testing Workshop
A workshop for learning how to test JavaScript applications
Stars: ✭ 1,276 (+4016.13%)
Mutual labels:  unit-testing, integration-testing
Java Dns Cache Manipulator
🌏 A simple 0-dependency thread-safe Java™ lib/tool for setting dns programmatically without touching host file, make unit/integration test portable.
Stars: ✭ 557 (+1696.77%)
Mutual labels:  unit-testing, integration-testing
Movieapp
🎬 MovieApp is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Dynamic Theme, Cache, Shimmer, Testing, Flavor, CI/CD, etc.
Stars: ✭ 117 (+277.42%)
Mutual labels:  unit-testing, integration-testing
puppeteer-lambda
Module for using Headless-Chrome by Puppeteer on AWS Lambda.
Stars: ✭ 117 (+277.42%)
Mutual labels:  headless, headless-chrome
Vue Testing Examples
Advanced testing with vuejs. When you need to go beyond Getting started section and see some real world example with everything that proper tests should have.
Stars: ✭ 288 (+829.03%)
Mutual labels:  unit-testing, integration-testing
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+12061.29%)
Mutual labels:  unit-testing, integration-testing

chromeless

AWS lambda with selenium & python is powerful solution. Let's access this benefit easily!

  • Don't create lambda functions every time. Just create this once.
  • Write the method.
  • Selenium dynamically execute your script.

Example

# Write the method to a file. (NOT interactive mode.)
def get_title(self, url):
    self.get(url)
    return self.title

# Attach the method and then call it.
from chromeless import Chromeless
chrome = Chromeless()
chrome.attach(get_title)
print(chrome.get_title("https://google.com")) # Returns Google

You can also provide boto3 session object if you don't want to use default aws profile:

from chromeless import Chromeless
from boto3.session import Session

session = Session(aws_access_key_id='<YOUR ACCESS KEY ID>',
                  aws_secret_access_key='<YOUR SECRET KEY>',
                  region_name='<REGION NAME>')
# or
session = Session(profile_name='<YOUR_PROFILE_NAME>')
chrome = Chromeless(boto3_session=session)

Or also you can just set appropriate environment vars works with boto3, so it will auto detect your choice e.g.:

# In mac or linux
export AWS_DEFAULT_REGION=<your aws region>

# In windows
set AWS_DEFAULT_REGION=<your aws region>

Installing

  • git clone --depth 1 https://github.com/umihico/pythonista-chromeless.git chromeless && cd $_
  • sls deploy --region YOUR_REGION
  • pip install chromeless

That's it! Now run the example.py and confirm your selenium works in lambda functions!

Tips

  • Don't call selenium native methods directly. Solution is wrapping.
# BAD EXAMPLE
chrome = Chromeless()
chrome.get("https://google.com") # Not a attached method. AttributeError will be raised.
chrome.title # Same. AttributeError.

# SOLUTION
def wrapper(self, url):
    self.get(url)
    return self.title

chrome = Chromeless()
chrome.attach(wrapper)
print(chrome.wrapper("https://google.com")) # prints 'Google'.
print(chrome.wrapper("https://microsoft.com")) # But you can execute as many times as you want.
print(chrome.wrapper("https://apple.com")) # Arguments are adjustable each time.
  • Multiple methods are also attachable.
def login(self):
    self.get("https://example.com/login")
    self.find_element_by_id("username").send_keys("umihico")
    self.find_element_by_id("password").send_keys("password")
    self.find_element_by_name("submit").click()

def test1(self):
    self.login()
    self.get("https://example.com/")

def test2(self):
    self.login()
    self.get("https://example.com/logout")

chrome = Chromeless()
chrome.attach(login) # You can attach multiple methods too.
chrome.attach(test1) # It means you can also refactor the common code.
chrome.attach(test2)
print(chrome.test1())
print(chrome.test2())
  • To screenshot
# BAD EXAMPLE
def bad_wrapper(self):
  self.get("https://google.com")
  self.save_screenshot("screenshot.png")
  # There's no sense in saving files in AWS Lambda.

# SOLUTION
def good_wrapper(self):
  self.get("https://google.com")
  return self.get_screenshot_as_png()
  # return image in binary format.

chrome = Chromeless()
chrome.attach(good_wrapper)
png = chrome.good_wrapper()
# then write then image down locally.
with open("screenshot.png", 'wb') as f:
    f.write(png)

License

The project is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].