I am trying to automate the testing of a web application whose HTML is rendered via javascript and not Java. I am able to login into the application using selenium as the login is just a HTML page. But once I enter the application, selenium webdriver isn't able to identify the web elements. I am using Selenium 2 + Java. I have even tried saving the web application as a HTML page and try accessing the web elements. No luck there as well.
Framework used is cucumber.
package Junit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;
import testBase.TestBase1;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class Feature3StepDef extends TestBase1{
@Given("^the application is open$")
public void the_application_is_open() throws Throwable {
System.setProperty("webdriver.ie.driver", "C:\\Selenium\\IEDriverServer.exe");
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
driver = new InternetExplorerDriver(ieCapabilities);
driver.get("http://******************/ccb-uata/SPLApp/cis.jsp");
System.out.println("I am In given");
}
@When("^User enters \"([^\"]*)\" and \"([^\"]*)\"$")
public void User_enters_and(String arg1, String arg2) throws Throwable {
new WebDriverWait(driver, 50);
WebElement user=driver.findElement(By.name("username"));
System.out.println("element is:" +user);
user.sendKeys(arg1);
WebElement psswd = driver.findElement(By.name("password"));
psswd.sendKeys(arg2);
WebElement button = driver.findElement(By.name("login"));
button.click();
System.out.println("I am In when");
Thread.sleep(10000);
WebElement elem = driver.findElement(By.xpath("//*body/div/table[@id='headerTable']"));
System.out.println("div element: " +elem);
Thread.sleep(100000);
System.out.println(arg1);
}
@Then("^the application should login$")
public void the_application_should_login() throws Throwable {
driver.quit();
System.out.println("I am In then");
}
}
HTML:
Person/Account
Premise
ID Type
ID Nbr
Account ID
Person ID
Premise ID
Error: org.openqa.selenium.TimeoutException: Timed out after 100 seconds waiting for presence of element located by: By.xpath: *[@id='headerDivision'] Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27' Driver info: driver.version: unknown at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:259) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228) at Junit.Feature3StepDef.User_enters_and(Feature3StepDef.java:53) at ?.When User enters "syahm" and "Powerful4"(Resources\Features\Feature3.feature:5) Caused by: org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == *[@id='headerDivision'] (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 343 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22' System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_27' Session ID: bb4475ec-3408-43f3-a7d2-22e2c0b94b66 Driver info: org.openqa.selenium.ie.InternetExplorerDriver Capabilities [{platform=WINDOWS, javascriptEnabled=true, cssSelectorsEnabled=true, handlesAlerts=true, browserName=internet explorer, nativeEvents=true, takesScreenshot=true, version=7}]