Created
February 23, 2010 02:56
-
-
Save mikitebeka/311801 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
| #!/usr/bin/env python | |
| import selenium, json | |
| def main(argv=None): | |
| import sys | |
| from optparse import OptionParser | |
| argv = argv or sys.argv | |
| parser = OptionParser("%prog ") | |
| parser.add_option("--sauce", help="run directly on sauce", | |
| dest="sauce", action="store_true", default=0) | |
| parser.add_option("--host", help="Selenium host", dest="host", | |
| default="localhost") | |
| parser.add_option("--browser", help="browser to test", dest="browser", | |
| default="*firefox") | |
| opts, args = parser.parse_args(argv[1:]) | |
| if args: | |
| parser.error("wrong number of arguments") # Will exit | |
| if opts.sauce: | |
| info = json.dumps({ | |
| "username" : "SAUCE_USER_NAME", | |
| "access-key" : "SAUCE_API_KEY", | |
| "os" : "Windows 2003", "browser" : "iexplore", | |
| "browser-version" : "6.", "job-name" : "Google Test"}) | |
| host = "saucelabs.com" | |
| else: | |
| host, info = opts.host, opts.browser | |
| sel = selenium.selenium(host, 4444, info, "http://google.com") | |
| sel.start() | |
| try: | |
| sel.open("http://google.com") | |
| sel.type("q", "Sauce Labs") | |
| sel.click("btnG") | |
| sel.wait_for_page_to_load(1000) | |
| assert sel.is_text_present("Selenium"), "can't find Selenium" | |
| finally: | |
| sel.close() | |
| sel.shut_down_selenium_server() | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment