Параллельное выполнение тестов на узле Windows и Mac-узле с использованием сетки селена пройдет все тесты, но не сможет запустить и пропустить первый тест FilterMoreResultsBySquareFeet для браузера Mac Firefox или браузера Windows Firefox.Он продолжает выдавать эту ошибку org.openqa.selenium.SessionNotCreatedException: Невозможно создать новый сервис: GeckoDriverService Я использую последнюю версию Java, последний драйвер селена, последнюю версию драйвера браузера и последнюю версию браузера.У меня есть все драйверы в одной папке, из которой я запускаю файлы сетки json selenium, и свойство системы кода указывает на эту же папку.Я также установил папку в пути в переменных среды в Windows, а также в пути на Mac.Кто-нибудь сталкивался с этой ошибкой и как вы ее решили?
public class TestBase {
private static ThreadLocal<WebDriver> driverThread = new ThreadLocal<>();
public static String whichNodeURL = "";
public static String nodeURL = "http://xxxx:4444/wd/hub";
public static String macNodeURL = "http://xxxx:5555/wd/hub";
public static String winNodeURL = "http://xxxx:5554/wd/hub";
DesiredCapabilities capabilities = new DesiredCapabilities();
@SuppressWarnings({ "rawtypes"})
@BeforeMethod (alwaysRun=true)
//Use before method instead of before class or before test so each method/test will open in new browser;
//This was tested and found before method was the only one that works.
@Parameters("browser")
public final void setDriver(String browser) throws IOException, InterruptedException{
ReadProperties.retrieveGlobalProperties();
if (ReadProperties.globalProp.getProperty("webautomation").contains("yes") && ReadProperties.globalProp.getProperty("mobileautomation").contains("no"))
{
if(browser.contains("winfirefox"))
{
System.setProperty("webdriver.gecko.driver", ReadProperties.globalProp.getProperty("pcgeckodriver"));
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setCapability("platform", "WINDOWS");
firefoxOptions.setCapability("browser", "firefox");
firefoxOptions.setCapability("newCommandTimeout", 5000);
firefoxOptions.setCapability(FirefoxDriver.MARIONETTE, true);
firefoxOptions.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
whichNodeURL=winNodeURL;
try
{
driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), firefoxOptions));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
else if(browser.contains("macfirefox"))
{
System.setProperty("webdriver.gecko.driver", ReadProperties.globalProp.getProperty("macgeckodriver"));
FirefoxOptions macfirefoxOptions = new FirefoxOptions();
macfirefoxOptions.setCapability("platform", "MAC");
macfirefoxOptions.setCapability("browser", "firefox");
macfirefoxOptions.setCapability("newCommandTimeout", 5000);
macfirefoxOptions.setCapability(FirefoxDriver.MARIONETTE, true);
macfirefoxOptions.setBinary("/Applications/Firefox.app/Contents/MacOS/firefox-bin");
whichNodeURL=macNodeURL;
try
{
driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), macfirefoxOptions));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
else if (browser.contains("winchrome"))
{
System.setProperty("webdriver.chrome.driver", ReadProperties.globalProp.getProperty("pcchromedriver"));
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("platform", "WINDOWS");
chromeOptions.setCapability("browser", "chrome");
chromeOptions.setCapability("newCommandTimeout", 5000);
whichNodeURL=winNodeURL;
try
{
driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), chromeOptions));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
else if (browser.contains("macchrome"))
{
System.setProperty("webdriver.chrome.driver", ReadProperties.globalProp.getProperty("macchromedriver"));
ChromeOptions macchromeOptions = new ChromeOptions();
macchromeOptions.setCapability("platform", "MAC");
macchromeOptions.setCapability("browser", "chrome");
macchromeOptions.setCapability("newCommandTimeout", 5000);
whichNodeURL=macNodeURL;
try
{
driverThread.set(new RemoteWebDriver(new URL(whichNodeURL), macchromeOptions));
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
String weburl = ReadProperties.globalProp.getProperty("weburl");
this.driverThread.get().get(weburl);
Thread.sleep(1000);
this.driverThread.get().manage().window().maximize();
Thread.sleep(1000);
}
}
}
public static WebDriver getDriver() {
return driverThread.get();
}
@AfterMethod(alwaysRun=true)
public static void OnFailure(ITestResult testResult) throws IOException {
if (testResult.getStatus() == ITestResult.FAILURE)
{
System.out.println(testResult.getStatus());
}
}
@AfterMethod(alwaysRun=true)
//Use after method instead of after class or after test so each method/test will open in new browser;
//This was tested and found after method was the only one that works.
public void tearDown() {
getDriver().quit();
}
}
public class FilterMoreResultsBySquareFeet extends TestBase{
static SoftAssert softAssert = new SoftAssert();
final static Logger log =
LogManager.getLogger(FilterMoreResultsBySquareFeet.class);
static String className =
FilterMoreResultsBySquareFeet.class.getSimpleName();
static Date date1= new Date();
static String originaltimestamp = new Timestamp(date1.getTime()).toString();
static String timestamp = originaltimestamp.replace(':', 'x').substring(11);
static String foldername = className+timestamp;
static String errorname = "";
@Parameters("browser")
@Test(groups= {"smoke", "regression"}, dataProvider = "getData")
public void filterResultsBySqFeet (String searchkeyword, String minsqfeet, String maxsqfeet) throws IOException, InterruptedException
{
WebDriver webdriver = getDriver();
Search.searchByCity(webdriver, searchkeyword);
FilterMoreResults_Page.clickOpenMoreFilters(webdriver);
FilterMoreResults_Page.filterBySqFeet(webdriver, minsqfeet, maxsqfeet);
FilterMoreResults_Page.applyMoreFilters(webdriver);
String diditfilter = FilterMoreResults_Page.verifyFilterBySqFeet(webdriver, minsqfeet, maxsqfeet);
try{
Assert.assertEquals(diditfilter, "yes");
}
catch(AssertionError e)
{
log.error("Didn't filter by square feet.", e.getMessage());
errorname = "didntfilterbysqft";
ScreenshotURL.screenshotURL(webdriver, foldername, errorname);
softAssert.fail();
}
softAssert.assertAll();
}
TESTNG FILE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="XOME Suite" parallel="tests" verbose="10" thread-count="2">
<test name = "Win Firefox Tests" preserve-order="true" group-by-instances="true">
<parameter name="browser" value="winfirefox">
<classes>
<class name="webTests.FilterMoreResultsBySquareFeet" />
<class name="webTests.FilterMoreResultsByKeyword" />
<class name="webTests.FilterMoreResultsByYear" />
</classes>
</parameter>
</test>
<test name = "Mac Firefox Tests" preserve-order="true" group-by-instances="true">
<parameter name="browser" value="macfirefox">
<classes>
<class name="webTests.FilterMoreResultsBySquareFeet" />
<class name="webTests.FilterMoreResultsByKeyword" />
<class name="webTests.FilterMoreResultsByYear" />
</classes>
</parameter>
</test>
<test name = "Win Chrome Tests" preserve-order="true" group-by-instances="true">
<parameter name="browser" value="winchrome">
<classes>
<class name="webTests.FilterMoreResultsBySquareFeet" />
<class name="webTests.FilterMoreResultsByKeyword" />
<class name="webTests.FilterMoreResultsByYear" />
</classes>
</parameter>
</test>
<test name = "Mac Chrome Tests" preserve-order="true" group-by-instances="true">
<parameter name="browser" value="macchrome">
<classes>
<class name="webTests.FilterMoreResultsBySquareFeet" />
<class name="webTests.FilterMoreResultsByKeyword" />
<class name="webTests.FilterMoreResultsByYear" />
</classes>
</parameter>
</test>
macnode.json
{
"capabilities":
[
{
"browserName": "firefox",
"marionette": true,
"maxInstances": 1,
"version": 66,
"platform": "MAC",
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 1,
"version": 73,
"platform": "MAC",
"seleniumProtocol": "WebDriver"
},
{
"browserName": "safari",
"technologyPreview": false,
"platform": "MAC",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 1,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://xxxx:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"cleanUpCycle": 5000,
"timeout": 5000,
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
hub.json
{
"host": null,
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher":
"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": 5000,
"cleanUpCycle": 5000,
"timeout": 300000,
"browserTimeout": 0,
"maxSession": 1
}
java -jar selenium-server-standalone-3.141.59.jar -role hub -hubConfig Hub.json
java -Dwebdriver.chrome.driver = "C: \\ seleniumgrid \\ chromedriver.exe" -Dwebdriver.gecko.driver = "C: \\ seleniumgrid \\ geckodriver.exe" -Dwebdriver.ie.driver = "C: \\ seleniumgrid \\ IEDriverServer.exe" -Dwebdriver.edge.driver = "C: \\ seleniumgrid \\ MicrosoftWebDriver.exe" -jar C: \\ seleniumgrid \\ selenium-server-standalone-3.141.59.jar -role узел -nodeConfig C: \\ seleniumgrid \\ WindowsNode.json
java -Dwebdriver.chrome.driver = "/ Users / abc / seleniumgrid / chromedriver" -Dwebdriver.gecko.driver= "/ Users / abc / seleniumgrid / geckodriver" -jar /Users/abc/seleniumgrid/selenium-server-standalone-3.141.59.jar -role node -nodeConfig /Users/abc/seleniumgrid/MacNode.json
org.openqa.selenium.SessionNotCreatedException: Unable to create new service: GeckoDriverService
Информация о сборке: версия: '3.141.59', версия: 'e82be7d358', время: '2018-11-14T08: 25: 53' Информация о системе: хост: 'abc-MacBook-Pro.local',IP: '2606: 6000: fccc: 1e00: 0: 0: 0: 6% en0 ', os.name:' Mac OS X ', os.arch:' x86_64 ', os.version: '10 .14.4', java.version:'1.8.0_212' Информация о драйвере: driver.version: неизвестно Продолжительность или время ожидания команды: 155 миллисекунд в org.openqa.selenium.remote.ErrorHandler.createThrowable (ErrorHandler.java:214) в org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed (ErrorHandler.java:166) в org.openqa.selenium.remote.JsonWireProtocolResponse.lambda $ errorHandler $ 0 (JsonWireProtocolResponse.java:54) в org.openqa.selenium.remote.sapon.sepon. $30) в org.openqa.selenium.remote.ProtocolHandshake.lambda $ createSession $ 0 (ProtocolHandshake.java:126) в java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java:193) в java.util.Spliterators $ArraySpliterator.tryAdvance (Spliterators.java:958) в java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:126) в java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.jav)a: 498) в java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485) в java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471) в java.util.stream.FindOps $ FindOp.evaluateSquen(FindOps.java:152) в java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) в java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:464) в org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:128) в org.openqa.selenium.remote.ProtocolHandshake.createSession (ProtocolHandshake.java:74) в org.openqa.selenium.remote.HttpCommandExecec.jpg (jt).openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:552) в org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:213) в org.openqa.seriverWote .ReverWote.Java: 131) в org.openqa.selenium.remote.RemoteWebDriver. (RemoteWebDriver.java:144) в base.TestBase.setDriver (TestBase.java:98) в java.util.concurrent.FutureTask.run (FutureTask.java:266) в java.util.concurrent.Executors $ RunnableAdapter.call (Executors.java:511)в java.util.concurrent.FutureTask.run (FutureTask.java:266) в java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149) в java.util.concurrent.ThreadPoolExcecutor: 624) at java.lang.Thread.run (Thread.java:748) Причина: org.openqa.selenium.SessionNotCreatedException: Невозможно создать новый сервис: GeckoDriverService Информация о сборке: версия: '3.141.59', редакция: 'e82be7d358 ', время:' 2018-11-14T08: 25: 53 'Информация о системе: хост:' abc-MacBook-Pro.local ', ip:' 2606: 6000: fccc: 1e00: 0: 0: 0: 6%en0 ', os.name:' Mac OS X ', os.arch:' x86_64 ', os.version: '10 .14.4', java.version: '1.8.0_212' Информация о драйвере: driver.version: неизвестно Информация о сборке: версия: '3.141.59', редакция: 'e82be7d358', время: '2018-11-14T08: 17: 03' Системная информация: хост: 'abc-MacBook-Pro.local', ip: '2606: 6000:fccc: 1e00: 0: 0: 0: 6% en0 ', os.name:' Mac OS X ', os.arch:' x86_64 ', os.version: '10 .14.4', java.version: '1.8.0_212 'Информация о драйвере: driver.version: неизвестно по адресу org.openqa.selenium.grid.session.remote.ServicedSession $ Factory.lambda $ получить $ 0 (ServicedSession.java:135) в org.openqa.selenium.grid.session.remote.ServicedSession $ Factory.apply (ServicedSession.java:152) в org.openqa.selenium.remote.server.ActiveSessionFactory.lambda $ применить $ 12 (ActiveSessionFactory.java:180) на java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java:193) на java.util.stream.ReferencePipeline $ 11 $ 1.accept (ReferencePipeline.Java: 373) в java.util.stream.ReferencePipeline $ 2 $ 1.accept (ReferencePipeline.java:175) в java.util.Spliterators $ ArraySpliterator.tryAdvance (Spliterators.java:958) в java.util.stream.ReferencePipeline.forlachWithC(ReferencePipeline.java:126) в java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:498) в java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485) в java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471) в java.util.stream.FindOps $ FindOp.evaluateSequential (FindOps.java:152) в java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) в java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:464) в org.openqa.selenium.remote.server.ActiveSessionFactory.apply (ActiveSessionFactory.java:183 at).openqa.selenium.remote.server.NewSessionPipeline.lambda $ null $ 2 (NewSessionPipeline.java:66) в java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java:193) в java.util.stream.ReferencePipeline $ 2$ 1.accept (ReferencePipeline.java:175) на java.util.Collections $ 2.tryAdvance (Collections.java:4717) на java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:126) на java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:498) в java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485) в java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471) в java.471 at..FindOps $ FindOp.evaluateSequential (FindOps.java:152) в java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) в java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:464) в org.openqa.selenium.remote.server.NewSessionPipeline.lambda $ createNewSession $ 3 (NewSessionPipeline.java:69) в java.util.stream.ReferencePipeline $.accept (ReferencePipeline.java:193) на java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java:193) на java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java:193) на java.util.stream.DistinctOps $ 1 $ 2.accept (DistinctOps.java:175) в java.util.stream.ReferencePipeline $ 2 $ 1.accept (ReferencePipeline.java:175) в java.util.stream.ReferencePipeline $ 3 $ 1.accept (ReferencePipeline.java: 193) в java.util.stream.ReferencePipeline $ 2 $ 1.accept (ReferencePipeline.java:175) в java.util.stream.Streams $ StreamBuilderImpl.tryAdvance (Streams.java:405)на java.util.stream.Streams $ ConcatSpliterator.tryAdvance (Streams.java:728) на java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:126) на java.util.stream.AbstractPipeline.copyIntoWithCancelP: 498) в java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:485) в java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:471) в java.util.stream.FindOps $ FindOp.evaluateSequencyFindOps.java:152) в java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234) в java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:464) в org.openqa.selenium.remote.server.NewSessionPipeline.createNewSession (NewSessionPipeline.java:72) в org.openqa.selenium.remote.server.commandhandler.BeginSession.execute (BeginSession.java:65) в org.openqa.selenium.remote.server.WebletriverServerer$ 0 (WebDriverServlet.java:235) ... еще 5 ... Удалено 16 кадров стека
[ОШИБКА] Выполнено тестов: 10, сбоев: 2, ошибкаrs: 0, пропущено: 1, истекло время: 287.762 с <<< НЕИСПРАВНОСТЬ!- в TestSuite [ОШИБКА] setDriver (webTests.FilterMoreResultsBySquareFeet) Прошло время: 6,55 с <<< НЕУДАЧИ!org.openqa.selenium.SessionNotCreatedException: Невозможно создать новый сервис: GeckoDriverService Информация о сборке: версия: '3.141.59', ревизия: 'e82be7d358', время: '2018-11-14T08: 25: 53' Информация о системе: хост:'abc-MacBook-Pro.local', ip: '2606: 6000: fccc: 1e00: 0: 0: 0: 6% en0', os.name: 'Mac OS X', os.arch: 'x86_64',os.version: '10 .14.4 ', java.version:' 1.8.0_212 'Информация о драйвере: driver.version: неизвестно Продолжительность или тайм-аут команды: 84 миллисекунды Причина: org.openqa.selenium.SessionNotCreatedException: Невозможно создать новую службу: GeckoDriverService Информация о сборке: версия: '3.141.59', редакция: 'e82be7d358', время: '2018-11-14T08: 25: 53' Информация о системе: хост: 'abc-MacBook-Pro.local', ip: '2606: 6000: fccc: 1e00: 0: 0: 0: 6% en0 ', os.name:' Mac OS X ', os.arch:' x86_64 ', os.version: '10 .14.4', java.version: '1.8.0_212' Информация о драйвере: driver.version: неизвестно Информация о сборке: версия: '3.141.59', версия: 'e82be7d358', время: '2018-11-14T08: 17: 03' Информация о системе: хост: 'abc-MacBook-Pro.local ', ip:' 2606: 6000: fccc: 1e00: 0: 0: 0: 6%en0 ', os.name:' Mac OS X ', os.arch:' x86_64 ', os.version: '10 .14.4', java.version: '1.8.0_212' Информация о драйвере: driver.version: неизвестно </p>