Read user input via JavaScriptExecutor or promt in Selenium Webdriver C #

0

I have 4 test environments.

When running the Selenium script, I want the user to tell me right after the browser opens, in which environment the script should run. So the script will direct the test to the correct environment.

Example:

  • If you enter 1, the script will direct the execution of the test in homologation.
  • If you enter 2, it will direct you to production, and so on.

I already have the script treatment, but I did not find any way for Selenium to read the user input.

Is it possible to display a popup in JavaScriptExecutor that has text field? Or even a prompt to read this user input?

Console.WriteLine and Console.ReadLine do not work in my Unit Test Project file.

    
asked by anonymous 07.11.2018 / 18:20

1 answer

0

You can call the command prompt Example:

prompt("Digite o ambiente", "");

But there you will need to somehow capture this return in the JSExecutor, I imagine you can do something like this:

String ambiente = (String) js.executeScript("prompt('Digite o ambiente', '');");
    
07.11.2018 / 18:40