Selenium Webdriver:未为WebDriver.TargetLocator类型定义方法alert() [英] Selenium Webdriver: The method alert() is undefined for the type WebDriver.TargetLocator

查看:195
本文介绍了Selenium Webdriver:未为WebDriver.TargetLocator类型定义方法alert()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Selenium Webdriver处理警报,根据selenium文档,正确的实现是:

I am trying to handle alerts using Selenium Webdriver, according the selenium documentation the correct implementation is:

Alert alert = driver.switchTo().alert();

但是我收到错误消息,类型WebDriver.TargetLocator的方法alert()未定义

However I am getting error message The method alert() is undefined for the type WebDriver.TargetLocator

Selenium 2的哪个版本具有此Web驱动程序api

what version of Selenium 2 has this web driver api

推荐答案

我正在使用硒2.3,它对我有用.据我所知,警报仅适用于仅具有确定"按钮的窗口.那就是您放置alert.accept();的地方我在警报中看到的另一个问题是它可能会跳过警报,因此您可能必须为该特定警报准备一条等待语句.希望这会有所帮助.

I'm using selenium 2.3 and it works for me. From what I've seen, alerts only work with windows that ONLY have the ok button. Thats where you put the alert.accept(); statement in. Another problem that I've seen with alerts is that it may jump over the alert so you may have to have a wait statement for that specific alert. Hope this helps.

这篇关于Selenium Webdriver:未为WebDriver.TargetLocator类型定义方法alert()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆