1

以下是似乎无法执行的测试用例代码。有没有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

+0

能否请附上错误输出运行测试,当你? – Thibstars

+0

测试用例失败输出屏幕截图 – User6

+0

我正在使用硒独立3.0.1和geckodriver以及它的显示空白morzilla浏览器选项卡打开。 – User6

回答

0

代码错误@

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

使用

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

“//” 应放置,而不是 “/”

+0

if(browser.equalsIgnoreCase(“火狐 “)){ \t \t \t \t \t \t \t \t \t System.setProperty(” webdriver.gecko.driver”, “C://MavenTest//driver//geckodriver.exe”); \t \t \t \t \t \t \t \t \t驱动=新FirefoxDriver(); \t \t \t \t \t \t \t} \t \t \t \t否则,如果(browser.equalsIgnoreCase( “铬”)){ \t \t \t \t \t \t \t \t \t System.setProperty( “webdriver.chrome.driver” “C:// // MavenTest司机// chromedriver。exe文件“); \t \t \t \t \t \t \t \t \t驱动=新ChromeDriver(); \t \t \t \t \t \t \t}我们为了check.So IGOT使用这个代码,铬驱动程序是工作正常Geckodriver 64bit版有没有新的依赖关系 – User6

+0

要使用geckodriver,你的firefox版本必须高于47。请检查并更新到最新版本 – RamaKrishna

1

最后我得到了answer.Do看是否有人获得配置失败与最新geckdriver和morzilla浏览器版本

使用此

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