serenity-bdd / serenity-jbehave

The Serenity integration for JBehave
39 stars 34 forks source link

When browser is set at runtime, on invoking a super.element method, the previous browser set get invoked. #254

Open SnehaJagdale opened 3 years ago

SnehaJagdale commented 3 years ago

In the framework, I am passing initial -Ddriver="chrome", now in application I am launching an opera driver for some negative tests.

EnvironmentVariables variables = SystemEnvironmentVariables.createEnvironmentVariables();
    this.operaDriverPath = variables.getProperty("webdriver.operadriver.driver");
    File file = new File(this.operaDriverPath);
    String absolutePath = file.getAbsolutePath();
    System.setProperty("webdriver.opera.driver", absolutePath);
    OperaDriver driver = new OperaDriver();
    driver.manage().window().maximize();   
    super.setDriver(driver);  ------> This I am able to set 

->>> Opera driver launches here.

When super.getDriver().navigate().to(URL); ->> URL is set.

In another class , invoking the webelements is handled.

By byFieldName=WebUtils.returnByBasedOnPageNameAndObjectName(pageName,fieldName); ->> getting the feild. super.element(byFieldName).waitUntilVisible(); - Log.info("Element visible : " + fieldName); return super.element(byFieldName).isVisible();

At this point allthough browser is set in Opera, browser from Chrome gets launched. Am I missing something here?

wakaleo commented 3 years ago

You can't really override the Serenity browser management like that. What problem are you trying to solve?

SnehaJagdale commented 3 years ago

So on the application I am working, we support Chrome, IEEdge, however for a certain scripts we need to verify that Opera isn't supported. Now we run our scripts in bulk, so basically I am designing the script in such a way, that although I invoke chrome, for this particular script once I set the browser to Opera. I should be able to validate some error messages.

1) Set OperaDriver at runntime. -> Success 2) Launch Application at runtime. -> Success 3) Do some validation, visibility check on the current browser set -> Failure, Chrome is launched.