我想从concordion打开一个浏览器。
正在尝试从System.java类打开浏览器。但是观察到WebDriver driver = new FirefoxDriver();没有被执行。
以下是我的项目的结构;

System.java类:-
package com.tutorialspoint;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class System {
public String initization(String browserName){
String url = null;
if (browserName=="firefox")
{
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
url = driver.getCurrentUrl();
}
return url;
}
}这是我的BrowserFixture.java类:
package specs.tutorialspoint;
@RunWith(ConcordionRunner.class)
public class BrowserFixture {
System system = new System();
public String initization(String browserName){
return system.initization(browserName);
}
}这是我的.html输入:
<html xmlns:concordion="http://www.concordion.org/2007/concordion">
<head>
<link href="../concordion.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Browser Initilization</h1>
<div class="example">
<h3>Example</h3>
<table>
<tr>
<th>browserName</th>
<th>initization</th>
</tr>
<tr concordion:execute="#result = initization(#browserName)">
<td concordion:set="#browserName">firefox</td>
</tr>
</table>
</div>
</body>
</html>发布于 2016-04-30 17:57:55
您需要使用string.equals(Object other)函数,而不是==运算符来比较字符串。
如果您替换以下内容,浏览器将正常打开:
if (browserName=="firefox")通过以下方式:
if (browserName.equals("firefox"))有关更多详细信息,请参阅How do I compare Strings in Java。
另请参阅我对此问题的评论,以了解有关此示例的一些一般观察。
https://stackoverflow.com/questions/36864599
复制相似问题