下面是测试用例代码,似乎无论如何都没有执行。 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();
}
}
}
答案 0 :(得分:1)
最后我得到了答案。看看是否有人因最新的geckdriver和morzilla浏览器版本而导致配置失败
使用此
System.setProperty("webdriver.firefox.marionette", "C://MavenTest//driver/geckodriver.exe");
答案 1 :(得分:0)
代码错误@
System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver/geckodriver.exe");
使用
System.setProperty("webdriver.gecko.driver", "C://MavenTest//driver//geckodriver.exe");
" //"应该放置而不是" /"