我有个问题。我通过Java自动化代码运行SOAPUIWeb服务测试。但在那之后。硒不起作用。似乎soapUI部分实际上没有完成。但我不确定。
public static void main(String[] args) throws Exception {
SoapUIRun srun = new SoapUIRun();
srun.runTestCase("CPIHS", "CPIHS");
new MainPage().LoginCad();
}
例外情况是:
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'GFG-GROUP153', ip: '10.100.1.7', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at screens.MainPage.LoginCad(MainPage.java:28)
at screens.MainPage.main(MainPage.java:87)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.NullPointerException
at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:79)
at org.apache.http.impl.conn.DefaultRoutePlanner.determineRoute(DefaultRoutePlanner.java:77)
at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:124)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:183)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 13 more
然而,我将SoapUI部分注释掉。它会再次发挥作用。比如:
public static void main(String[] args) throws Exception {
//SoapUIRun srun = new SoapUIRun();
//srun.runTestCase("CPIHS", "CPIHS");
new MainPage().LoginCad();
}
以下是我的SoapUI方法:
public void runTestCase(String tarSuite, String tarCase) throws Exception {
String reportStr = "";
TestRunner runner;
SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
WsdlProject project = new WsdlProject("C:\\Users\\tshi\\Documents\\Maven Projects\\ASORT\\WebServiceResource\\Suncorp_Issuing-soapui-project.xml");
List<TestSuite> suiteList = project.getTestSuiteList();
for (TestSuite aSuiteList : suiteList) {
String suiteName = aSuiteList.getName();
List<TestCase> caseList = aSuiteList.getTestCaseList();
//System.out.println("Test Suite: " + suiteName);
if (suiteName.equals(tarSuite)) {
for (TestCase aCaseList : caseList) {
String caseName = aCaseList.getName();
//System.out.println("Test Case: " + caseName);
if (caseName.equals(tarCase)) {
long startTime = System.currentTimeMillis();
runner = project.getTestSuiteByName(suiteName).getTestCaseByName(caseName).run(new PropertiesMap(), false);
long duration = System.currentTimeMillis() - startTime;
reportStr = reportStr + "\n\tTestCase: " + aCaseList.getName() + "\tStatus: " + runner.getStatus() + "\tReason: " + runner.getReason() + "\tDuration: " + duration;
System.out.print(reportStr);
}
}
}
}
}
以下是硒的相关方法:
public void LoginCad(){
System.setProperty("webdriver.chrome.bin", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
String bank = Integer.toString(48);
String emp = Integer.toString(200003);
String pwd = "Cadencie1";
String baseUrl = "http://172.16.1.133:8090/AppName/servlet/app";
driver = new ChromeDriver();
driver.get(baseUrl);
try {
Thread.sleep(1000);
} catch(InterruptedException e){
// TO DO Auto-generated catch block
e.printStackTrace();
}
Utilities.switchToWindow("AppName - User Logon [LOGON]", driver);
try{
Thread.sleep(2000);
} catch(InterruptedException e){
// TO DO Auto-generated catch block
e.printStackTrace();
}
driver.findElement(By.id("idBANK")).clear();
driver.findElement(By.id("idBANK")).sendKeys(bank);
driver.findElement(By.id("idEMPLOYEE")).clear();
driver.findElement(By.id("idEMPLOYEE")).sendKeys(emp);
driver.findElement(By.id("idPASSWORD")).clear();
driver.findElement(By.id("idPASSWORD")).sendKeys(pwd);
driver.findElement(By.id("maintLOGON")).click();
driver.findElement(By.id("idPASSWORD")).clear();
driver.findElement(By.id("idPASSWORD")).sendKeys(pwd);
driver.findElement(By.id("maint")).click();
}
任何人都知道为什么会这样。我在谷歌上搜索。但在同样的情况下,似乎没有人会犯同样的错误。非常感谢你。
感谢@albciff提供的解决方案,但对我的情况没有帮助。我终于创建了新的代理:
report.step("Verify 'proxySelector' not NULL");
ProxySelector proxy = ProxySelector.getDefault();
if (proxy == null) {
//Creating new Proxy
ProxySelector proxySelector = new ProxySelector() {
@Override
public List<Proxy> select(URI uri) {
return new ArrayList<Proxy>(){{
add(Proxy.NO_PROXY);
}};
}
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
}
};
report.report("Set new proxySelector (Proxy.NO_PROXY)", Reporter.WARNING);
ProxySelector.setDefault(proxySelector);
}else{
report.report("Proxy is not NULL continue..");
}
如果问题仅在SOAPUI执行之后发生在selenium上,那么可能是某些SOAPUI配置导致了问题。问题可能是由于SOAPUI将默认代理设置为null
,然后当selenium尝试获取代理以检查配置时,会收到NullPointerExcetpion
。
基于您的错误跟踪:
Caused by: java.lang.NullPointerException
at org.apache.http.impl.conn.SystemDefaultRoutePlanner.determineProxy(SystemDefaultRoutePlanner.java:79)
如果你看一下org的源代码。阿帕奇。http。impl。conn.SystemDefaultRoutePlanner
类别:
(注意我保持行号与您的错误跟踪相关)
53 public class More ...SystemDefaultRoutePlanner extends DefaultRoutePlanner {
54
55 private final ProxySelector proxySelector;
56
57 public More ...SystemDefaultRoutePlanner(
58 final SchemePortResolver schemePortResolver,
59 final ProxySelector proxySelector) {
60 super(schemePortResolver);
/*
proxySelector ARE NULL AND ProxySelector.getDefault();
RETURNS ALSO NULL DUE THAT SOAPUI PROBABLY MAKE BEFORE
ProxySelect.setDefault(null);
*/
61 this.proxySelector = proxySelector != null ? proxySelector : ProxySelector.getDefault();
62 }
63
64 public More ...SystemDefaultRoutePlanner(final ProxySelector proxySelector) {
65 this(null, proxySelector);
66 }
67
68 @Override
69 protected HttpHost More ...determineProxy(
70 final HttpHost target,
71 final HttpRequest request,
72 final HttpContext context) throws HttpException {
73 final URI targetURI;
74 try {
75 targetURI = new URI(target.toURI());
76 } catch (final URISyntaxException ex) {
77 throw new HttpException("Cannot convert host to URI: " + target, ex);
78 }
/* HERE IS THE NULLPOINTER */
79 final List<Proxy> proxies = this.proxySelector.select(targetURI);
所以一个可能的解决方案是自己处理ProxySelect。然后,您可以尝试以下解决方案:
import java.net.ProxySelector;
...
public static void main(String[] args) throws Exception {
// get default proxy before soapui will set it to null
ProxySelector proxy = ProxySelector.getDefault();
SoapUIRun srun = new SoapUIRun();
srun.runTestCase("CPIHS", "CPIHS");
// set it again to avoid NPE on selenium
ProxySelector.setDefault(proxy);
new MainPage().LoginCad();
}
我是Spring world的新手,刚刚将pom.xml更新到gradle中来管理所有的依赖项。 格雷迪被社区抛弃了吗?还有,这个错误可能的根本原因是什么。 刚刚意识到Spring Boot有很多令人困惑的错误消息。我真的不认为这种错误消息对任何开发人员都有帮助。对这种错误有什么想法或方向吗? 我只知道我换了球。xml转换为gradle并手动迁移配置文件。非常感谢! 异常在线程"main"java
我在Win7 x32上使用SoapUI Pro 5.1.2,并尝试在Groovy Teststep中连接到Selenium WebDrive。 为此,我添加了v2。45.0在文件夹中。 我的Groovy测试步骤代码: 当我尝试运行此步骤时,SoapUI返回消息: 在添加相同的打包到空java项目。它已经顺利完成了! 这是soapUI的错误日志: 我也尝试使用代替,得到了同样的错误。
问题内容: 我想在我的spring-boot应用程序开始监视目录更改后运行代码。 我尝试运行新线程,但此时尚未设置服务。 我已经能够找到,它会在设置注释之前触发。理想情况下,一旦应用程序准备处理http请求,我希望触发该事件。 在Spring Boot中启动应用程序后,是否有更好的事件可以使用,或者有更好的代码运行方式? 问题答案: 尝试:
我开始开发projet,现在使用windows。基本上,我可以使用maven生成一个Jar文件,但当我尝试运行Jar文件时,它并不好用。听起来好像没有找到hibernate属性。 我的错误: 我的Hibernate配置位于\src\main\Resources\application.properties 我怎么处理? [更新] 使用mvn spring boot运行时,我可能会得到不同的结果:r
问题内容: 运行硒测试时,我在启动IE 11时遇到问题。这是我用来设置浏览器的代码 我尝试了基于此线程的其他解决方案,但还是没有运气。堆栈链接。有什么我可以使用的解决方案吗? Environmental : Selenium version: 3.12.0 Iedriverserver version: 3.9.0.0 Ie version: 11.0.65 控制台输出: 堆栈跟踪: 问题答案:
问题内容: 我的日食没有启动,因为我的计算机有点死机了,所以我不得不强制重新启动它。当我不得不重新启动时,Eclipse是打开的,我相信这很可能是原因。我不知道该如何解决。每当我尝试打开它时,它都会告诉我检查工作区中的.log文件,并显示: http://paste.strictfp.com/26579 而且我不知道如何解决它。请帮忙? 问题答案: 您缺少 第125行的 类,您必须重新安装才能解决