【发布时间】:2018-02-17 17:45:10
【问题描述】:
我正在尝试编写一个简单的夹具来打开浏览器并导航到 www.google.com。当我运行 wiki 页面时,它以全绿色通过,但浏览器永远不会打开(我认为该方法甚至不会被 wiki 调用)。有人可以看看我的夹具和 wiki 看看我做错了什么吗?提前非常感谢,
这是维基 -
!|SeleniumFitness|
|URL |navigateToSite?|
|http://www.google.com| |
运行后-
!|SeleniumFitnesse| java.lang.NoSuchMethodError: org.openqa.selenium.remote.service.DriverCommandExecutor.<init>(Lorg/openqa/selenium/remote/service/DriverService;Ljava/util/Map;)V
|URL |The instance decisionTable_4.setURL. does not exist|navigateToSite?
|http://www.google.com|!The instance decisionTable_4.navigateToSite. does not exist |
这是夹具 -
package FitNesseConcept.fitNesse;
import java.util.Properties;
import org.junit.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeMethod;
//import com.google.common.base.Preconditions.*;
//import com.google.common.collect.Lists;
import fit.ColumnFixture;
public class SeleniumFitnesse extends ColumnFixture {
public static ChromeDriver driver = null;
private String navigateToSite = "";
public String URL = "";
public SeleniumFitnesse() {
Properties props = System.getProperties();
props.setProperty("webdriver.chrome.driver", "/home/ninad/eclipse-workspace/chromedriver");
driver = new ChromeDriver();
}
// SET-GET Methods
public String getURL() {
return URL;
}
public void setURL(String uRL) {
URL = uRL;
}
public String getNavigateToSite() {
return navigateToSite;
}
public void setNavigateToSite(String navigateToSite) {
this.navigateToSite = navigateToSite;
}
// Navigate to URL
public void navigateToSite() throws Throwable {
System.out.println("Navigating to Website");
try {
driver.navigate().to(URL);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
【问题讨论】:
-
您编写自己的(又一个)Selenium FitNesse 集成的任何特殊原因?您是否查看了fitnesse.org/PlugIns#slimfixtures 的可用插件?
-
你为什么要写一个Fit column fixture,你想创建某种形式的决策表吗?当我查看代码和 wiki 时,我无法完全理解您期望该表代表什么。当你想使用一个表来按顺序执行多个步骤(比如打开一个页面)时,我建议切换到 Slim 测试运行器并使用它的脚本表 (fitnesse.org/…)。您当前的代码使用了 jUnit
BeforeMethod注释,这在 FitNesse 上下文中并不意味着或做任何事情。 -
感谢您的回复。我不知道 slimfixture 插件。你能一步一步告诉我如何将它们导入我的eclipse项目。是否像添加 maven 依赖一样简单?如果没有,罐子到底在哪里?非常感谢(仅供参考 - 我是初学者到中级,我已经习惯了 Cucumber,但我工作的公司想要健身)。
-
(警告:我有偏见,因为以下项目是我的)。我建议根据github.com/fhoeben/… 中描述的方法之一创建您自己的 FitNesse Maven 项目。这为您提供了一个 FitNesse 项目,您可以在其中使用“BrowserTest”夹具 (github.com/fhoeben/hsac-fitnesse-fixtures/wiki/…) 来执行 Selenium 测试。但是您不必使用整个设置,您也可以将其添加为 maven 项目(请参阅项目的发布),但是需要更多的手动配置
标签: selenium fitnesse fitnesse-slim selenium-fitnesse-bridge