-1

I have been practicing to automate few scenarios for web application way2Automation.com and struggling to enter the text in Registration form coming as the popup. I have done some research already and tried many ways mentioned below:

a) Using WebDriverWait and explicit wait b) Using Implicit wait and Thread.sleep c) Using JavaScriptExecutor

But none of them worked for me and I am still stuck to register the user. Would really appreciate the help. Below are the artificats

URL: http://way2automation.com/way2auto_jquery/index.php

way2atuomation

Code trials:

1)

//  WebElement ele = driver.findElement(By.xpath("//*[@id='load_form']/div/div[2]/input"));
//  JavascriptExecutor executor = (JavascriptExecutor)driver;
//  executor.executeScript("arguments[0].click();", ele);
//  WebElement button = driver.findElement(By.xpath("//*[@id=\"load_form\"]/div/div[2]/input"));
//  new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(button));
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

To click on SUBMIT you can use either of the following Locator Strategies:

  • cssSelector:

    driver.findElement(By.cssSelector("input.button[value='Submit']")).click();
    
  • xpath:

    driver.findElement(By.xpath("//input[@class='button' and @value='Submit']")).click();
    

However, as the element is a dynamic element so to click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.button[value='Submit']"))).click();
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='button' and @value='Submit']"))).click();
    

Reference

You can find a detailed discussion on NoSuchElementException in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0
You need to handle windows
Try the below code and let me know updates

 driver.get("http://way2automation.com/way2auto_jquery/index.php");
        String parent=driver.getWindowHandle();
        String child=driver.getWindowHandle();
        driver).switchTo().window(child);
        driver.findElement(By.name("name")).sendKeys("Abhishek Saxena");
Justin Lambert
  • 940
  • 1
  • 7
  • 13