51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 2606|回复: 3
打印 上一主题 下一主题

Selenium2.0中调用selenium1.0API的问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-10-27 10:00:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
网上查到的是这样:
  1. // You may use any WebDriver implementation. Firefox is used here as an example
  2. WebDriver driver = new FirefoxDriver();

  3. // A "base url", used by selenium to resolve relative URLs
  4. String baseUrl = "http://www.google.com";

  5. // Create the Selenium implementation
  6. Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);

  7. // Perform actions with selenium
  8. selenium.open("http://www.google.com");
  9. selenium.type("name=q", "cheese");
  10. selenium.click("name=btnG");

  11. // And get the underlying WebDriver implementation back. This will refer to the
  12. // same WebDriver instance as the "driver" variable above.
  13. WebDriver driverInstance = ((WebDriverBackedSelenium) selenium).getUnderlyingWebDriver();
复制代码
现在的问题是就是提示getUnderlyingWebDriver这个方法未定义. 导入的包如下:
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import com.thoughtworks.selenium.Selenium;
是还缺少什么包? 还是什么情况,请知道的朋友帮助解决,多谢!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2012-10-30 09:51:06 | 只看该作者
你这个代码……好乱。
我看了一下你的import,如果你在用WebDriver类,那么这个类在哪里import了?WebDriver类都没有,下面的根本不用看了。
还有,我看了一下WebDriverBackedSelenium这个类,根本没有getUnderlyingWebDriver这个方法的。唯一能返回一个WebDriver对象的方法是getDrappedDriver,其他都是返回的DefaultSelenium对象。所以我想你应该是写错了吧。我不知道你从哪里看到的这段代码,根本没什么用,特别是最后那一句。
建议学习一下java基础知识。
回复 支持 反对

使用道具 举报

该用户从未签到

3#
 楼主| 发表于 2012-10-31 08:55:15 | 只看该作者
回复 2# 六月天
谢谢你的回复. "如果你在用WebDriver类,那么这个类在哪里import了" 这个我肯定是导了的,我是为了说明问题,所以代码没有粘的太全.  这段代码也是在网上查阅到的. 查seleniujm2.0调用1.0API 查到的几乎都是使用getUnderlyingWebDriver这个方法, 我查看了相关jar包的源码,确实不存在. 后来在官网上看最新的文档,确实时使用不存在.所以疑惑. 后来在官网上看最新的文档,确实是使用getDrappedDriver.

但现在的问题是: 在昨晚一个新增保存操作后,本是弹出一个alert提示保存成功的,但是现在不管用2.0的方式还是用1.0的方式都获取不到这个Alert
回复 支持 反对

使用道具 举报

该用户从未签到

4#
发表于 2013-2-20 13:43:15 | 只看该作者
抓取不到换一种方法啊
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-5-7 19:05 , Processed in 0.079083 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表