我正在运行selenium服务器(v.2.0b2)并编写一个python脚本,以便在我的webapp上运行一个测试套件。
from selenium import webdriver
import selenium
selenium = selenium.selenium('127.0.0.1', 3333, '*firefox', 'http://localhost/')
selenium.start()
profile = webdriver.FirefoxProfile('selenium')
browser = webdriver.Firefox(profile)
browser.get('http://localhost:8080/index.html?no_auto_login=1')我有一个登录按钮,它会弹出一个确认对话框,但它需要在服务器之间来回往返,然后才会弹出。
submit_button = browser.find_element_by_css_selector('#btnSubmit')
submit_button.click()
alert = browser.switch_to_alert()
assert alert.text == 'Server Login Error...'
alert.accept()注释掉submit_button.click()之后的项,然后调用selenium.is_confirmation_present()返回false
如何等待确认框可见?为什么selenium.is_confirmation_present()不返回true?
发布于 2011-03-12 17:57:32
我没有使用Selenium 2.0 (web驱动程序),但建议您使用Thread.sleep(10)进行测试。如果这是可行的,那么在您的情况下就意味着需要有条件的等待。
https://stackoverflow.com/questions/5277860
复制相似问题