I want to execute a paste to a local variable already exist to an input text with selenium webdriver in java. for this I used this method:
public static void copyText(final String id, final String text) throws Exception {
waitForJQueryProcessing(DRIVER, N_30);
WebElement elem = DRIVER.findElement(By.id(id));
DRIVER.findElement(By.id(id)).clear();
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
StringSelection strSel = new StringSelection(text);
clipboard.setContents(strSel, null);
elem.sendKeys(Keys.chord(Keys.CONTROL, "v", text));
System.out.println(text);
}
When I execute the test, i will appear empty I don't know why ?
Aucun commentaire:
Enregistrer un commentaire