Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Successful tests when selenium grid is not reachable #1304

Closed
tempuser14 opened this issue Jul 13, 2018 · 3 comments
Closed

Successful tests when selenium grid is not reachable #1304

tempuser14 opened this issue Jul 13, 2018 · 3 comments

Comments

@tempuser14
Copy link

We have a Selenium Grid (managed by Zalenium) on which our tests run. The current problem is that the build passes when the grid is not reachable (and no tests acutally run).

Jul 13, 2018 3:03:54 PM org.openqa.selenium.remote.DesiredCapabilities firefox
INFORMATION: Using new FirefoxOptions() is preferred to DesiredCapabilities.firefox()
Jul 13, 2018 3:03:54 PM org.openqa.selenium.remote.DesiredCapabilities firefox
INFORMATION: Using new FirefoxOptions() is preferred to DesiredCapabilities.firefox()
[pool-1-thread-1] WARN net.thucydides.core.pages.Pages - Failed to instantiate page of type class pages.LoginPage (net.serenitybdd.core.exceptions.SerenityManagedException: zalenium.domain could not be reached)
net.thucydides.core.pages.WrongPageError: The page object class pages.LoginPage looks dodgy:
Failed to instantiate page (net.serenitybdd.core.exceptions.SerenityManagedException: zalenium.domain could not be reached)
at net.thucydides.core.pages.Pages.thisPageObjectLooksDodgy(Pages.java:293)
at net.thucydides.core.pages.Pages.getCurrentPageOfType(Pages.java:219)
at net.thucydides.core.pages.Pages.getPage(Pages.java:90)
at net.thucydides.core.steps.PageObjectDependencyInjector.instantiatePageObjectIfNotAssigned(PageObjectDependencyInjector.java:55)
at net.thucydides.core.steps.PageObjectDependencyInjector.injectDependenciesInto(PageObjectDependencyInjector.java:33)
at net.thucydides.core.steps.StepFactory.injectOtherDependenciesInto(StepFactory.java:166)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:156)
at net.thucydides.core.steps.StepFactory.instantiateNewStepLibraryFor(StepFactory.java:139)
at net.thucydides.core.steps.StepFactory.getNewStepLibraryFor(StepFactory.java:86)
at net.thucydides.core.steps.IndividualInstancesByDefaultStepCreationStrategy.initiateStepsFor(IndividualInstancesByDefaultStepCreationStrategy.java:16)
at net.thucydides.core.steps.StepAnnotations.instantiateAnyUnitiaializedSteps(StepAnnotations.java:76)
at net.thucydides.core.steps.StepAnnotations.instanciateScenarioStepFields(StepAnnotations.java:60)
at net.thucydides.core.steps.StepAnnotations.injectScenarioStepsInto(StepAnnotations.java:42)
at net.serenitybdd.junit.runners.SerenityRunner.injectScenarioStepsInto(SerenityRunner.java:593)
at net.serenitybdd.junit.runners.SerenityRunner.methodInvoker(SerenityRunner.java:557)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:273)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at net.serenitybdd.junit.runners.SerenityRunner.performRunChild(SerenityRunner.java:460)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:435)
at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:42)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at org.apache.maven.surefire.junitcore.pc.InvokerStrategy.schedule(InvokerStrategy.java:54)
at org.apache.maven.surefire.junitcore.pc.Scheduler.schedule(Scheduler.java:346)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:239)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Running test.LoginLogoutTest
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec - in test.LoginLogoutTest

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

The LoginPage:

public LoginPage(WebDriver driver) throws IOException {
    super(driver);
    Properties properties = new Properties();
    properties.load(getClass().getResourceAsStream("/profile.properties"));
    driver.get(properties.getProperty("url"));//navigate to the main page
}
  1. I didn't expect that the framework simply logs a WARN message when a Page object could not be instantiated and considers it success.
  2. How can one get access to a property defined in maven's pom.xml? (we would like to avoid the profile.properties file where maven resource plugin replaces placeholders)
  3. One can argue that it is not a good idea to navigate to a certain page in the page constructor. The wanted effect was to always and as early as possible load the LoginPage. Are there good workarounds for this so that tests fail when Selenium is not reachable and still load the LoginPage as early as possible?
@wakaleo
Copy link
Member

wakaleo commented Jul 15, 2018

You should not invoke the driver during the constructor, as you have little control when the constructor is invoked. The failure may happen outside of the normal Serenity lifecycle, and may not be reported correctly. Best practice is to call the open() method at the start of your test.

@tempuser14
Copy link
Author

tempuser14 commented Jul 16, 2018

I will try to remain organized with the discussion and stick to the numbering in my original question.

  1. Can we count on a fix in one of the next minor releases? The problem seems bigger than this: if any exceptions occur during constructor (any means everything from NoSuchMethodException to any exceptions).
  2. Any ideas here?
  3. OK: best practice is to call WebDriver.open() at the test start.

@immidisrikanth
Copy link

Hi ,

I am using Serenity in my Automation project, While implementing Grid I initiated Remote driver but Inbuilt method of BDD getDriver() method is used in scripts. Remote Driver initiated in Hooks is getting overridden by getDriver() method in Pages.class (inbuilt method from serenity).

Due to this tests are not running on Node.

Hooks.java:

Remotedriver = new RemoteWebDriver(new URL("http://10.128.32.43:4444/wd/hub"), ieOptions);
In scripts :

getDriver().findElement(By.xpath("//input[contains(@data-bind,'closingReferenceId')]")).click();

Thanks for help

Thanks,
Srikanth

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants