Trigger alert using Selenium in Java

0

In addition to manipulating javascript alerts with Selenium WebDriver , would it be possible to invoke Selenium code runtime alerts in the browser?

I would like to create the 3 javascript alert types below using selenium :

  • alerta
  • confirmação
  • prompt de entrada.

To facilitate understanding ...

WebDriver driver = new ChromeDriver();
driver.get("https://www.w3schools.com/JS/");

I want to invoke the 3 alert types below with dynamic values.

    
asked by anonymous 09.11.2018 / 20:59

1 answer

1

I think with JavaScript to do, something like:

driver.executeScript("window.alert('teste')")
String confirmation = driver.executeScript("return window.confirm('confirmação')");
String result = driver.executeScript("return prompt('Por favor, insira seu nome:', 'Harry Potter')");

Source: link

    
04.12.2018 / 19:42