下面是测试用例代码,无论如何似乎都没有执行。 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();
}
}
}
最佳答案
终于我得到了答案。看看是否有人在使用最新的 geckdriver 和 morzilla 浏览器版本时遇到配置失败
使用这个
System.setProperty("webdriver.firefox.marionette", "C://MavenTest//driver/geckodriver.exe");
关于java - 无法访问浏览器 :Session Not Created Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40235243/