0
I have a certain difficulty in instantiating the driver in another class. What happens is the following:
I have two definition classes of steps
First:
public class TranscricaoSadtStep {
static WebDriver driver = Web.openBrowser();
Autorizacoes_InicialPage inicial;
AutorizacoesSite_Page autorizacoes;
TranscricaoSadt_Page sadt;
Atendimento_Page atendimento;
@Given("^que acessei o menu transcricao$")
public void queAcesseiOMenuTranscricao() throws Throwable {
inicial = new Autorizacoes_InicialPage(driver);
inicial.navigateTo();
this.inicial.selecionarUsuario("MARCELO DA SILVEIRA MACHADO");
this.inicial.clickQaAutorizacoes();
String oldTab = driver.getWindowHandle();
autorizacoes = new AutorizacoesSite_Page(driver);
this.autorizacoes.trocarAba(oldTab, 0);
this.autorizacoes.menuTranscricao();
}
@Given("^cliquei no submenu SADT$")
public void cliqueiNoSubmenuSADT() throws Throwable {
this.autorizacoes.submenuSadt();
sadt = new TranscricaoSadt_Page(driver);
}
Second:
WebDriver driver;
AutorizacoesSite_Page autorizacoes;
TranscricaoInternacao_Page internacao;
Atendimento_Page atendimento;
@Given("^cliquei no submenu solicitacao de internacao$")
public void cliqueiNoSubmenuSolicitacaoDeInternacao() throws Throwable {
autorizacoes.submenuInternacao();
internacao = new TranscricaoInternacao_Page(driver);
}
That is, it executes the first step of class 1 and then tries to execute the first step of class 2, because that is how it is written in Feature.
Only that it occurs NullPointException
when it tries to run in class 2. And I already know the reason is that the driver is null, but I don’t know how to boot it.
Someone has a suggestion?
Good evening, all right? From what I read, you need to carry out an implementation of this Webdriver. There is a material in the following link containing the implementation in Firefox and Chrome. Link: https://artoftesting.com/automationTesting/launching-browsers-in-selenium.html
– Caio Augusto Papai
Actually, Webdriver is already implemented. It opens the browser, executes the step of class 1, and then it must execute the step of class 2. And that’s when it becomes null. What I need is for it to perform the class 2 step in the same open window, as it is the continuation of the test. That is, it opens the browser, click on the menu (step of class 1) then you must click on the submenu of that menu (class 2).
– Mozara Gysi