0

Im using automation with Selenium and JAVA (Eclipse) and im trying to aplying an automation test but i cant select the "prompt box" for inssert the text into the fields...

my code dont send "text" to my fields

this is a windows like a pop up where i need insert text and clic on "Aceptar", but actually my code doesn't work, just open the navigator and clic in the button and the test finished..

this is my code:

package Driver;
    import java.util.regex.Pattern;
    import javax.swing.JOptionPane;
    import java.util.concurrent.TimeUnit;
    import org.testng.Assert;
    import org.testng.annotations.*;    
    import com.thoughtworks.selenium.webdriven.commands.SelectWindow;
    import static org.testng.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.server.handler.GetAllWindowHandles;
import org.openqa.selenium.support.ui.Select;
import java.io.*;


public class Parametria {


public static void main (String[] args) throws Exception{

    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();

    driver.get("MY WWWW URL");
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    driver.findElement(By.id("form:table:buttonAdd")).click();

    driver.switchTo().frame("form:panelAdd_content");
    driver.findElement(By.id("form:headerType")).clear();
    driver.findElement(By.xpath("//*[@id='form:headerType']']")).sendKeys("Parametro_1");
//  driver.findElement(By.name("form:headerType']']")).sendKeys("Parametro_1");
    driver.findElement(By.id("form:nameType")).clear();
    driver.findElement(By.xpath("//*[@id='form:nameType']")).sendKeys("Parametro_2");
    driver.findElement(By.xpath("//*[@id='form:value1']/span")).click();
    driver.findElement(By.xpath("//*[@id='form:j_idt72']")).click();

    driver.navigate().back();
    driver.quit();

}

}

Blackwidow
  • 13
  • 5
  • You should use explicit waits to wait for you pop up like window and then handle it as usual WebElement. Look here for reference: http://stackoverflow.com/questions/14939298/handling-a-popup-window-using-selenium?rq=1 – Ivan Pronin May 04 '17 at 20:40
  • Just i need that my window has text in the fields... – Blackwidow May 04 '17 at 20:52
  • try fetching aceptar first to see whether driver is able to interact with the pop-up – Kushal Bhalaik May 05 '17 at 05:46
  • What I can see, it's neither a pop-up nor within​ a iframe so, `driver.switchTo().frame();` doesn't makes sense to me. Can you try to switching through window handles? – undetected Selenium May 05 '17 at 06:54

0 Answers0