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

Asked

Viewed 108 times

1

I have 4 test environments.

When executing the Selenium script, I want the user to inform soon after the browser opens, in which environment the script should be executed. So the script will direct the test to the correct environment.

Example:

  • If you type 1, the script will direct the execution of the test under approval.
  • If you type 2, it will direct to production, and so on.

I already have the treatment in the script, but I couldn’t find any way for Selenium to read the user input.

Is it possible to display a pop-up 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.

1 answer

1

You can call the command prompt Example:

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

But then you will need to somehow capture this return in Jsexecutor, I imagine you can do something more or less like this:

String ambiente = (String) js.executeScript("prompt('Digite o ambiente', '');");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.