Skip to content

Instantly share code, notes, and snippets.

@gumdropsteve
Last active October 17, 2020 03:19
Show Gist options
  • Save gumdropsteve/0f8ecb1a1e7fc37a6e0bfedf72e4464c to your computer and use it in GitHub Desktop.
Save gumdropsteve/0f8ecb1a1e7fc37a6e0bfedf72e4464c to your computer and use it in GitHub Desktop.
Simple test to see if Selenium is correctly installed
from time import sleep
from selenium import webdriver
story = 'https://medium.com/dropout-analytics/selenium-and-geckodriver-on-mac-b411dbfe61bc'
story = story + '?source=friends_link&sk=18e2c2f07fbe1f8ae53fef5ad57dbb12' # 'https://bit.ly/2WaKraO' <- short link
def gecko_test(site_000=story):
"""
simple overview:
1) set up webdriver
2) load this article
3) close up shop
input:
>> site_000
> default: url of this article ('friend link')
"""
# set the driver
driver = webdriver.Firefox()
# load this article
driver.get(site_000)
# and chill a bit
sleep(7)
# k, cool. let's bounce.
driver.quit()
# make runable
if __name__ == '__main__':
# here we go
gecko_test()
@gumdropsteve
Copy link
Author

gumdropsteve commented Oct 17, 2020

Same Test for Chromedriver

from time import sleep
from selenium import webdriver

story = 'https://medium.com/dropout-analytics/selenium-and-geckodriver-on-mac-b411dbfe61bc'
story = story + '?source=friends_link&sk=18e2c2f07fbe1f8ae53fef5ad57dbb12'   # 'https://bit.ly/2WaKraO' <- short link

def chrome_test(site_000=story):
    """
    simple overview:
        1) set up webdriver
        2) load this article 
        3) close up shop 
    
    input:
        >> site_000
            > default: url of this article ('friend link')
    """
    # set the driver 
    driver = webdriver.Chrome()

    # load this article 
    driver.get(site_000)

    # and chill a bit (6-12 seconds)
    from numpy import random
    sleep(random.randint(6, 12))

    # k, cool. let's bounce. 
    driver.quit()


# make runable 
if __name__ == '__main__':
    # here we go
    chrome_test()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment