Example code for using the Selenium 2 Python bindings. — Gist
2012-07-16 19:52
666 查看
Example code for using the Selenium 2 Python bindings. — Gist
# To install the Python client library:# pip install -U selenium# Import the Selenium 2 namespace (aka "webdriver")from selenium import webdriver# iPhonedriver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub')# Androiddriver = webdriver.Remote(browser_name="android", command_executor='http://127.0.0.1:8080/hub')# Google Chrome driver = webdriver.Chrome()# Firefox driver = webdriver.Firefox()# ------------------------------# The actual test scenario: Test the codepad.org code execution service.# Go to codepad.orgdriver.get('http://codepad.org')# Select the Python language optionpython_link = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]python_link.click()# Enter some text!text_area = driver.find_element_by_id('textarea')text_area.send_keys("print 'Hello,' + ' World!'")# Submit the form!submit_button = driver.find_element_by_name('submit')submit_button.click()# Make this an actual test. Isn't Python beautiful?assert "Hello, World!" in driver.get_page_source()# Close the browser!driver.quit()
相关文章推荐
- Selenium Two Tutorial using IronPython and InternetExplorerDriver - The Automated Tester
- SQL code for the partitoned example
- pywebkitgtk - Python bindings for the WebKit GTK+ port - Google Project Hosting
- cefpython - Python bindings for embedding the Chrome browser - Google Project Hosting
- Looking for an example for inserting content into the response using a servlet filter
- pywebkitgtk - Python bindings for the WebKit GTK+ port - Google Project Hosting
- "No Python interpreter configured for the project " in Pycharm for python selenium
- The Essentials for Using COM in Managed Code
- Python-selenium:Protected Mode settings are not the same for all zones.
- Pseudo code for In-class QuestionExample 3: Write pseudo code that performs the following: Ask a use
- could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
- WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform… using builtin-ja
- GetPageHTML - Get the HTML code for a given URL
- Using the AngularJS Package for Sublime Text
- 解决selenium 启动ie浏览器报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones
- Job for vsftpd.service failed because the control process exited with error code
- [IT学习]Learn Python the Hard Way (Using Python 3)笨办法学Python3版本
- How to send custom http_headers for RPC calls using python xmlrpclib?
- Do not apply "using" for the client---WCF Client
- The Classical Example using DOM to operate a XML File