comparison trivSelenium.py @ 2:e07789816ca5

adding more python files from lib/python on origen
author Henry Thompson <ht@markup.co.uk>
date Mon, 09 Mar 2020 16:48:09 +0000
parents
children
comparison
equal deleted inserted replaced
1:0a3abe59e364 2:e07789816ca5
1 # To install the Python client library:
2 # pip install -U selenium
3
4 # Import the Selenium 2 namespace (aka "webdriver")
5 from selenium import webdriver
6
7 # iPhone
8 #driver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub')
9
10 # Android
11 #driver = webdriver.Remote(browser_name="android", command_executor='http://127.0.0.1:8080/hub')
12
13 # Google Chrome
14 #driver = webdriver.Chrome()
15
16 # Firefox
17 driver = webdriver.Firefox()
18
19 # ------------------------------
20 # The actual test scenario: Test the codepad.org code execution service.
21
22 # Go to codepad.org
23 driver.get('http://codepad.org')
24
25 # Select the Python language option
26 python_link = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]
27 python_link.click()
28
29 # Enter some text!
30 text_area = driver.find_element_by_id('textarea')
31 text_area.send_keys("print 'Hello,' + ' World!'")
32
33 # Submit the form!
34 submit_button = driver.find_element_by_name('submit')
35 submit_button.click()
36
37 # Make this an actual test. Isn't Python beautiful?
38 assert "Hello, World!" in driver.get_page_source()
39
40 # Close the browser!
41 driver.quit()