java - Selenium 不适用于歌剧

标签 java selenium selenium-webdriver selenium-rc

我正在创建一个程序来进入我的路由器并调整设置,并从不同的浏览器执行此操作,我有 FF、Chrome 和 IE 可以工作。我在 Opera 上尝试的一切都不起作用。它只打开两个选项卡,一个带有 127.0.0.1:some_crazy_port# 和 file:///C:/Users/EETEST~1/AppData/Local/Temp/opera4672404649060883314profile/ 当我试图到达时,192.168.0.1

系统:Windows 7:Eclipse Kepler & Selenium 2.37.0

这是我的代码:

import com.opera.core.systems.OperaDriver;
import com.thoughtworks.selenium.*;

import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.Select;

public class NewTest extends SeleneseTestCase {

private WebDriver cDriver;
private String baseUrl;


    public void setUp() throws Exception{
        baseUrl = "192.168.0.1";//Heres the destination
        System.setProperty("webdriver.opera.driver", "C:\\Program Files (x86)\\Opera");
        cDriver = new OperaDriver();//Setting up the OperaDriver
    }

    @Test
    public void test() throws Exception{
        try{
            cDriver.navigate().to(baseUrl);//Go!
            //Thread.sleep(5000);//Everything below is just doing stuff on the page
            cDriver.findElement(By.id("radioButtonssBasic")).click();
            Select selector = new Select(cDriver.findElement(By.id("ap")));
            selector.selectByValue("0SSIDisNAMED"+router);
            cDriver.findElement(By.name("passphrase1")).sendKeys(routerPass);
            cDriver.findElement(By.name("passphrase2")).sendKeys(routerPass);
            cDriver.findElement(By.id("user")).sendKeys(user);
            cDriver.findElement(By.name("password1")).sendKeys(userPass);
            cDriver.findElement(By.name("password2")).sendKeys(userPass);
            cDriver.findElement(By.id("submitButton")).click();
        }finally{
        Thread.sleep(2000);
        cDriver.quit();
        }

最佳答案

对于 12 以下的 Opera 版本,使用 OperaPrestoDriver https://github.com/operasoftware/operaprestodriver

Opera 版本 12 以上,使用operachromiumdriver https://github.com/operasoftware/operachromiumdriver/releases

关于java - Selenium 不适用于歌剧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19942198/

相关文章:

java - 如何使用 Selenium 允许位置访问?

java - 在 Android 中使用来自 Google Places API 的 JSON 响应

java - Struts 表单和 Javascript

java - 无法使用 selenium webdriver 进行鼠标悬停操作

javascript - Selenium webdriver 在 node.js 中迭代和导航多个链接

java - 如何在 Java 中使用 Selenium 提交表单

python - 如何在 Repl.it 上使用 Selenium ?

java - 处理共享 IntelliJ 项目的 .IML 文件中的重大(但无意义)持续更改

java - 如何避免在多线程时访​​问相同的静态计数器

python - Selenium 使用 .find 方法返回空列表,即使有项目