Sendkey is not able to use due to "onpaste="return false" | Selenium Forum
M
Posted on 08/07/2016
Issue:
Unable to enter number in "tenure" field using sendkey as element is showing as "onpaste="return false; [/b]

I got few solution but that solution also not working


1) JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementByID('applied_tenure').setAttribute('value', '55' )");

or
2) driver.findElement(By.id("password")).sendKeys("12121212"+Keys.ENTER);

M
Replied on 08/07/2016

try actions class. if that doesn't work then try robot class.


M
Replied on 12/07/2016

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


M
Replied on 13/07/2016

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]


M
Replied on 13/07/2016

Thanks a lot code is running fine