Hi,
I am trying to execute the test classes in parallel in Chrome instance.
I had set thread count as 3, three instances of browser got opened.
But the username and password gets kkeyed in in the same instance.
Below is the BaseSet up , where I initialize the driver:
public static WebDriver driver;
@Parameters({ "browserType" })
@BeforeClass(alwaysRun = true)
public void initializeTestBaseSetup(@Optional("chrome") String browserType) throws MalformedURLException {
setDriver(browserType);
}
@AfterClass(alwaysRun = true)
public void baseSetupLogOut() {
driver.quit();
}
public WebDriver getDriver() {
return driver;
}
private void setDriver(String browserType) throws MalformedURLException {
switch (browserType) {
case "chrome":
driver = initChromeDriver();
break;
case "firefox":
driver = initFirefoxDriver();
break;
case "IE":
driver = initIEDriver();
break;
default:
driver = initChromeDriver();
}
}
private WebDriver initChromeDriver() throws MalformedURLException {
if ("remote".equalsIgnoreCase(mode)) {
DesiredCapabilities capability = DesiredCapabilities.chrome();
driver = new RemoteWebDriver(new URL(hubUrl), capability);
driver.manage().window().maximize();
} else if ("local".equalsIgnoreCase(mode)) {
System.setProperty("webdriver.chrome.driver", "drivers/Chrome/chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--start-maximized");
driver = new ChromeDriver(chromeOptions);
} else {
throw new IllegalArgumentException("Unsupported mode '" + mode + "'");
}
driver.get(miningUrl);
return driver;
}And I try to do login action, before class (this is in different class and test classes extend this class):@BeforeClass(alwaysRun = true)
public void baseSetupLogin() {
commonUtils.login();
objDemoHomePage = new DemoHomePage(driver);
objLogin = new LoginPage(driver);
}Kindly help me to resolve the problem and execute tests in parallel.Thanks,Kuzhali
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c523b49d-dbb1-41b5-90ad-d71264732c1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Scott,
>>>> It's quite common to see a run that specifies a thread count of 10 to end up launching 12 or more tests simultaneously, with a corresponding number of browser sessions.
That to me would be a straight forward bug either in the Test code that is responsible for browser instantiation or the underlying TestRunner. It should be fixed. For me that wouldn’t be a reason for trying to check for alternatives.
>>>> In my Selenium framework, I acquire drivers from a local instance of Selenium Grid.
Yes, I remember going down that rabbit hole myself a couple of years back. For local executions (which is mostly the case when you are doing test development and would like to see the browser kick off and watch your test in action to debug), requiring a local instance of Selenium Grid (the one that you spin off via your code, wherein you fire up a hub, fire up a node, wire them together) to come up before browser instances can be allocated to me sounds like too much of an ask.
Local executions should be seamless. They should be making use of the more specific RemoteWebDriver variants such as ChromeDriver, FirefoxDriver etc., instead of having to rely on RemoteWebDriver. From a framework perspective it makes sense to try and keep everything standard to always a RemoteWebDriver. In that case, one should try using the DriverService variant (but it’s a lot of overhead and one is better off with using ChromeDriver directly for e.g.,) Something like the below sample.
public static void main(String[] args) throws IOException {
DriverService service = ChromeDriverService.createDefaultService();
service.start();
URL url = service.getUrl();
RemoteWebDriver driver = new RemoteWebDriver(url, new ChromeOptions());
driver.get("http://www.google.com");
System.err.println("Title " + driver.getTitle());
driver.quit();
service.stop();
}
>>>> The Grid hub configuration provides explicit control over the maximum number of session that will be active at any given moment.
If this is the only reason why you are using a local grid, then you could consider alternatives. One such alternative would be to guard your browser instantiation and cleanup via methods that are guarded by Semaphores for e.g., Am sure there are other elegant ways of achieving this as well.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/484d7d40-3ac8-42a1-9515-b66e8c5fb9a0%40googlegroups.com.
Scott,
>>>> If I logged a bug with the TestNG team that stated, "I get 12 tests running simultaneously when I set the thread count to 10," they're likely to tell me that this is normal behavior.
I am one of the committers in TestNG. Trust me, I am not going to come back to you and say that if you set a thread count of 10 and if you notice 12 tests running simultaneously that’s normal behavior. That is a bug. A straight forward bug. Thread-count of 10 in TestNG would mean that TestNG would at any given point in time only run 10 @Test annotated methods at a time. I say this because I know how TestNG works. So, if you have an example wherein you are seeing things otherwise, then it needs to be investigated and fixed. So please help share a sample for that.
>>>> Different browsers expend different amounts of system resources. If you're targeting multiple browsers with your automation, this requires driver-specific management of the maximum instances of any given browser.
Yes. Absolutely correct. But that doesn’t mean one would need to rely on a remote execution mechanism (which is what the Grid is actually meant for) to basically do that management when it can very well be managed by a sophisticated test runner (such as TestNG for example).
>>>> The ability to change the targeted driver and add new browsers by simply updating your configuration is huge.
A well-designed framework should be able to manage this by still letting you specify the browser flavor via a configuration and also specify if it’s a local or a remote run and yet achieve them by toggling between FirefoxDriver/ChromeDriver/InternetExplorerDriver etc., for local runs and using RemoteWebDriver only for remote runs. Its not that difficult.
>>>> The elimination of behavioral anomalies between local and remote operation avoids a lot of frustration.
I must correct you here. There are no behavioral anomalies between local and remote operation. The grid is just a sophisticated load distribution mechanism. Nothing more and nothing less.
If you take a closer look at the Selenium node implementation you will notice that it still resorts to invoking the same FirefoxDriver or ChromeDriver but via reflection. Just because a test runs a UI automation testcase locally by employing a selenium grid spawned via code, doesn’t get rid of any frustrations that managing a Grid is associated with.
Because things such as ephemeral port exhaustion, selenium node leaking memory due it running for a longer time are still going to come up in a remote execution environment which you will never see in a locally spun off grid via code and whose lifetime is short.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/87ee60a8-5b42-44e9-84bb-202cc8c91651%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/53d4c694-f50e-4d05-ab1e-a9079fe5aab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class ChromeDriver extends RemoteWebDriver public class EdgeDriver extends RemoteWebDriver public class FirefoxDriver extends RemoteWebDriver public class InternetExplorerDriver extends RemoteWebDriver public class OperaDriver extends RemoteWebDriver public class SafariDriver extends RemoteWebDriver |
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/54427a6d-e1f6-47f1-bb5e-1648ab21b141%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public class ScreenshotOnFailure extends BaseSetup implements IHookable {
@Override
public void run(IHookCallBack callBack, ITestResult testResult) {
callBack.runTestMethod(testResult);
if (testResult.getThrowable() != null) {
try {
takeScreenShot(testResult.getMethod().getMethodName());
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Attachment(value = "Failure in method {0}", type = "image/png")
private byte[] takeScreenShot(String methodName) throws IOException {
return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7fd57389-4729-425d-86fd-f3e0f11d03ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/cEBYO-RaYis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLnUq1AY6br8M0RO9yDyigA3Pzn%2BS0dps-y_W4f%3DK7biBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANOO4NbXRsd14pC9opKfwwfNdmm-CBE0bN136-cqNv_EeVi4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLmgaUPxFq2DeK23j6Dz-cqtr3ztbSojVnPdqF-p8fV0Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Ok, Thank you. I will try with that version and post on Tuesday(we have long weekend).
On Thu, 14 Jun 2018 at 10:15 PM, ⇜Krishnan Mahadevan⇝ <krishnan.mahadevan1978@gmail.com> wrote:
Please retry using 6.14.3 and kindly post back your findings.On Thu 14 Jun, 2018, 22:11 Kuzhali Velmurugan, <kuzhali.v...@gmail.com> wrote:
Yes, I face the issue while using TestNG, have added the listener in the XML file.But am not using the latest version of TestNG.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7fd57389-4729-425d-86fd-f3e0f11d03ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
----Thanks & Regards
Krishnan Mahadevan"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/My Technical Scribbings @ http://rationaleemotions.wordpress.com/
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/cEBYO-RaYis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLnUq1AY6br8M0RO9yDyigA3Pzn%2BS0dps-y_W4f%3DK7biBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
----Regards,V.Poonkuzhali
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANOO4NbXRsd14pC9opKfwwfNdmm-CBE0bN136-cqNv_EeVi4nw%40mail.gmail.com.--
For more options, visit https://groups.google.com/d/optout.
--Thanks & Regards
Krishnan Mahadevan"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/My Technical Scribbings @ http://rationaleemotions.wordpress.com/
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/cEBYO-RaYis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLmgaUPxFq2DeK23j6Dz-cqtr3ztbSojVnPdqF-p8fV0Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--Regards,V.Poonkuzhali
Please share a full fledged simple standalone test, that can be used to reproduce the problem.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
From: <seleniu...@googlegroups.com> on behalf of Kuzhali Velmurugan <kuzhali.v...@gmail.com>
Reply-To: <seleniu...@googlegroups.com>
Date: Friday, June 22, 2018 at 6:10 PM
To: Selenium Users <seleniu...@googlegroups.com>
Subject: Re: [selenium-users] Re: Parallel execution
Hi,
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/7fd57389-4729-425d-86fd-f3e0f11d03ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Thanks & Regards
Krishnan Mahadevan"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/cEBYO-RaYis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLnUq1AY6br8M0RO9yDyigA3Pzn%2BS0dps-y_W4f%3DK7biBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.--
Regards,
V.Poonkuzhali
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANOO4NbXRsd14pC9opKfwwfNdmm-CBE0bN136-cqNv_EeVi4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.--
Thanks & Regards
Krishnan Mahadevan"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/cEBYO-RaYis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CANikZLmgaUPxFq2DeK23j6Dz-cqtr3ztbSojVnPdqF-p8fV0Nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
--
Regards,
V.Poonkuzhali
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ae194197-eb1d-49e9-9d9f-792480af08ff%40googlegroups.com.
Hi ,
By adding the below 2 highlighted lines, resolved the issue when the screen capture method is added as a listener.
And web driver instance will not be null and screenshot gets attached to allure report.