We want to use Google App Engine to run Selenium tests with cron every 4 hours (later we may change this number of hours). We want to receive an email with the results of the tests. I want to know how I create the first test. I want to test https://inbox.google.com/ with our extension with Google Chrome - enter our website, login, click "Save changes", install the extension, then enter https://inbox.google.com/, login and check that the extension works. The problem is that I don't know how to setup the tests, do I have to setup them with a URL and how do I do it? Do I have to give each test a different URL or can I run all the tests with one URL? Here is the code I received from http://app.crossbrowsertesting.com/selenium/run:
# Please visit http://selenium-python.readthedocs.org/en/latest/index.html for detailed installation and instructions
import unittest
from selenium import webdriver
class SeleniumCBT(unittest.TestCase):
def setUp(self):
caps = {}
caps['name'] = 'Chrome Inbox Test'
caps['build'] = '1.0'
caps['browser_api_name'] = 'Chrome39x64'
caps['os_api_name'] = 'Win8.1'
caps['screen_resolution'] = '1280x1024'
caps['record_video'] = 'true'
caps['record_network'] = 'true'
caps['record_snapshot'] = 'true'
#start the remote browser on our server
self.driver = webdriver.Remote(
desired_capabilities=caps,
command_executor="http://[username]:[password]@hub.crossbrowsertesting.com:80/wd/hub"
)
self.driver.implicitly_wait(20)
def test_CBT(self):
#load the page url
print('Loading Url')
self.driver.get('http://crossbrowsertesting.github.io/selenium_example_page.html')
#maximize the window
print('Maximizing window')
self.driver.maximize_window()
#check the title
print('Checking title')
self.assertTrue("Selenium Test Example Page" in self.driver.title)
def tearDown(self):
print("Done with session %s" % self.driver.session_id)
self.driver.quit()
if __name__ == '__main__':
unittest.main()
I also downloaded Selenium (2.44.0) and put it in the libs
directory, if I include the following lines:
import sys
sys.path.insert(0, 'libs')
Can I import selenium? (from selenium import webdriver
) or do I have to do something else?
We are using Python 2.7 (although we can upgrade to Python 3).