首页IT科技example for(Example code for using the Selenium 2 Python bindings. — Gist)

example for(Example code for using the Selenium 2 Python bindings. — Gist)

时间2025-09-19 12:46:32分类IT科技浏览5528
导读:# pip install -U selenium...

# pip install -U selenium
# Import the Selenium 2 namespace (aka "webdriver")
from selenium import webdriver
# iPhone
driver = webdriver.Remote(browser_name="iphone", command_executor=http://172.24.101.36:3001/hub)
# Android
driver = 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.org
driver.get(http://codepad.org)
# Select the Python language option
python_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. Isnt Python beautiful?
assert "Hello, World!" in driver.get_page_source()
# Close the browser!
driver.quit()
声明:本站所有文章                ,如无特殊说明或标注                      ,均为本站原创发布               。任何个人或组织       ,在未征得本站同意时                ,禁止复制               、盗用                       、采集       、发布本站内容到任何网站        、书籍等各类媒体平台                       。如若本站内容侵犯了原著者的合法权益                       ,可联系我们进行处理       。

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
怎么用python读取excel文件(python如何将实例用作属性)