Created
March 31, 2017 01:51
-
-
Save tonetheman/bdfeae5d0a7240210ed664a6cf32fc8f to your computer and use it in GitHub Desktop.
Python code showing Selenium script for http://www.yachtworld.com/. Running now, results in a minute...
This file contains 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 our WebDriver object | |
from selenium import webdriver | |
import requests | |
def run_test(): | |
try: | |
driver = None | |
#we need to use CBT capabilities | |
caps = {} | |
caps["browser_api_name"] = "Chrome56x64" | |
caps["name"] = "Selenium Conference Example" | |
caps["os_api_name"] = "Win10" | |
caps["record_video"] = "true" | |
url = "http://www.yachtworld.com/" | |
#Instantiate a RemoteWebDriver pointed at CBT hub | |
driver = webdriver.Remote(desired_capabilities=caps,command_executor="http://user@yourdomain.com:yourauthkey@hub.crossbrowsertesting.com:80/wd/hub") | |
#navigate to our URL | |
driver.get(url) | |
#change the window width to see if our page is responsive | |
for width in range(1366,512,-20): | |
driver.set_window_size(width,768) | |
driver.maximize_window() | |
# begin visiting some links on our URL driver.find_element_by_link_text("advanced search").click() | |
if driver.title == "Advanced Boat Search": | |
print("The title is correct!") | |
driver.get(url) | |
driver.find_element_by_link_text("Ranger Tugs R31").click() | |
if driver.title == "Boats for Sale - New and Used Boats and Yachts - YachtWorld.com": | |
print("The title is correct!") | |
driver.get(url) | |
driver.find_element_by_link_text("Mag Bay Yachts 33 Center Console").click() | |
if driver.title == "Boats for Sale - New and Used Boats and Yachts - YachtWorld.com": | |
print("The title is correct!") | |
driver.get(url) | |
driver.find_element_by_link_text("Azimut 64 Flybridge").click() | |
if driver.title == "Boats for Sale - New and Used Boats and Yachts - YachtWorld.com": | |
print("The title is correct!") | |
driver.get(url) | |
except: | |
print("CaughtError") | |
finally: | |
driver.quit() | |
run_test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment