【发布时间】:2014-10-13 12:04:45
【问题描述】:
当用户输入错误的用户名和密码时,我正在尝试获取放置在页面 (js) 上的文本“Incorrect Credentials”...
login_button.click()
self.driver.implicitly_wait(10) # seconds
get_conformation_message = self.driver.find_element(By.XPATH, '//*[@id="toast-container"]/div/div[1]')
noz.assert_equal(get_conformation_message.text, "Incorrect Credentials")
我已将等待时间设置为 10 秒,以确保该元素在页面上,但我的测试仍然失败,并显示......
noz.assert_equal(get_conformation_message.text, "Incorrect Credentials") nose.proxy.AssertionError: '' != 'Incorrect Credentials'+ 不正确的凭据
这是渲染的 html...
<div ng-repeat="toaster in toasters" class="toast ng-scope toast-error" ng-class="toaster.type"
ng-click="click(toaster)" ng-mouseover="stopTimer(toaster)" ng-mouseout="restartTimer(toaster)" style="">
<button class="toast-close-button" ng-show="config.closeButton">×</button>
<div ng-class="config.title" class="ng-binding toast-title">Incorrect Credentials</div>
<div ng-class="config.message" ng-switch="" on="toaster.bodyOutputType" class="toast-message">
<!-- ngSwitchWhen: trustedHtml --><!-- ngSwitchWhen: template --><!-- ngSwitchDefault: -->
<div ng-switch-default="" class="ng-binding ng-scope">Incorrect Email/Password</div>
</div>
</div>
我怎样才能让它在 Selenium 中工作?
【问题讨论】:
-
您确定
get_confirmation_message代表您需要的对象吗?
标签: javascript python selenium