Hi,
Implemented "Robot class" and I am able to login to application but i need to use downkey where sendkey is not able to use that is not working.
Used explicit wait but element only not detected. Using sendkey not able to enter any data
Code attached here
there is something wrong with ID of that element please check with dev team
in the mean time use this.
[code:23ops16s]package com.sample;
import java.awt.Robot;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
public class TestLogin {
WebDriver driver;
@Test
public void TestRobo() throws Exception {
// Open Firefox
driver = new FirefoxDriver();
// Maximize the window
driver.manage().window().maximize();
// Open facebook
driver.get("http://54.169.212.13/app");
driver.findElement(By.id("emailid")).sendKeys("t@t.om");
driver.findElement(By.id("password"))
.sendKeys("12121212" + Keys.RETURN);
// Create object of Robot class
Robot r = new Robot();
// Press Enter
// r.keyPress(KeyEvent.VK_ENTER);
// Release Enter
// r.keyRelease(KeyEvent.VK_ENTER);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(
By.xpath("//*[@id='t-s-sign' and @title='Apply for New Loan' and @type='submit']"))
.click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
List<WebElement> allRadios_personal = driver.findElements(By
.id("salaried_personal"));
allRadios_personal.get(0).click();
driver.findElement(
By.xpath("//*[@id='loanamount' and @name='loan_amount']"))
.sendKeys("40");
List<WebElement> allRadios = driver.findElements(By
.name("loan_amount_um"));
allRadios.get(1).click();
System.out.println(driver.findElements(
By.xpath("//*[@placeholder=\"Please Enter Loan Tenure (in months)\"]")).size());
driver.findElement(
By.xpath("//*[@placeholder=\"Please Enter Loan Tenure (in months)\"]")).sendKeys("3");
// driver.findElement(By.id("applied_tenure")).sendKeys("3");
// r.keyPress(KeyEvent.VK_DOWN);
}
}[/code:23ops16s]