java - 无法访问浏览器 :Session Not Created Exception

标签 java maven selenium selenium-webdriver selenium-firefoxdriver

下面是测试用例代码,无论如何似乎都没有执行。 Firefox 是否有任何配置问题?

package testOperations;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class FunctionalTest {

    //Code for launching the required link into browser

    WebDriver driver;

    @BeforeTest

    public void  launchUrl() {

    System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver/geckodriver.exe");
       driver = new FirefoxDriver();

        driver.get("https://letskodeit.teachable.com/p/practice");

    }

运行代码时,仅打开空白浏览器窗口,并且测试用例失败。

    @Test

    public void radioButtoncheck() {

    boolean list = driver.findElements(By.tagName("radio")).get(2).isSelected();

        if  (list!=true) {

            driver.findElement(By.id("hondaradio")).click();
        }
        else {

            driver.findElement(By.id("benzradio")).click();
        }

    }

}

Output screenshot

最佳答案

终于我得到了答案。看看是否有人在使用最新的 geckdriver 和 morzilla 浏览器版本时遇到配置失败

使用这个

System.setProperty("webdriver.firefox.marionette", "C://MavenTest//driver/geckodriver.exe");

关于java - 无法访问浏览器 :Session Not Created Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40235243/

相关文章:

java - Spring 安全和 UserDetailsS​​ervice

java - 禁止导入某些传递性 Maven 依赖项

selenium IDE - 如何存储超链接地址然后访问该 URL?以前工作过

python - 输入关键字列表以在网站上搜索字段并将结果保存到外部 HTML 文件

python - 使用 Selenium 或请求填写表格

java - 如何彻底卸载Android系统应用程序?

java - 从两个数据库表获取结果并在 Java 中设置它和另一个 Jframe?

java - 我想开发适用于 iPhone 和 Android 的应用程序。使用哪个框架更好?

java - Spring Boot,maven编译错误

gitlab中的maven settings.xml重复