Last active
January 22, 2018 18:22
-
-
Save awkwords/f953ec3e3ee7ac6587dd030db05a1211 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import sys | |
import argparse | |
import ConfigParser | |
from selenium import webdriver | |
from colorama import Fore, Back, Style | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
from selenium.webdriver.chrome.options import Options | |
selenium_grid_url = 'http://creds' | |
def log(thing): | |
print(Fore.BLUE + '[carttester]: ' + Fore.WHITE + thing + Style.RESET_ALL) | |
print "This is the name of the script:" , sys.argv[0] | |
print "number of arguments:", len(sys.argv) | |
print "the arguments are:", str(sys.argv) | |
client_url = sys.argv[1] | |
product_url = sys.argv[2] | |
cart_url = client_url + '/index.php/checkout/cart' | |
project_url = sys.argv[3] | |
print('client-url:', client_url) | |
print('product-url:', product_url) | |
print('cart-url:', cart_url) | |
print('project_url:', project_url) | |
profile = webdriver.FirefoxProfile() | |
profile.set_preference("general.useragent.override", "allybot") | |
desired_cap = DesiredCapabilities.FIREFOX.copy() | |
desired_cap['acceptSslCerts'] = True | |
desired_cap['project'] = project_url | |
print(desired_cap) | |
try: | |
driver = webdriver.Remote( | |
desired_capabilities=desired_cap, | |
browser_profile=profile, | |
command_executor=selenium_grid_url) | |
except WebDriverException: | |
print('browserstack could be having issues, breaking exit 0') | |
exit(0) | |
driver.get(client_url) | |
driver.get(product_url) | |
atc = driver.find_element_by_id('product-addtocart-button') | |
atc.click() | |
time.sleep(5) | |
driver.get(cart_url) | |
if ('You have no items in your shopping cart.' in driver.page_source): | |
print('their was a error with the cart') | |
driver.quit() | |
exit(1) | |
time.sleep(5) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment