-
Selenium Webdriver
I am trying to paste a date using the form 03012017 into the date form with a code of: *
Code:
<input name="ctl00$ContentPlaceHolder2$response_def06a4c-a2c3-4120-a165-7ed24d106c6e" value="__/__/____" id="ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e" class="textboxcontrol" type="text">
I'm using selenium on eclipse and I am trying to put the date that is in the excel sheet pasted into a form that does not allow ctrl+v so either using the sendkeys(); method in which I have tried but failed or by right clicking and selecting the paste option.
The code that I have so far is:
Code:
if(Headers[a].equals("datePartA")){ String v_datePartA = formatter.formatCellValue(sheet.getRow(i).getCell(a));
// driver.findElement(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")).clear();
// driver.findElement(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")).click();
StringSelection stringSelection = new StringSelection(v_datePartA);
System.out.println("stringSelection is " + stringSelection);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Clipboard clipboard = toolkit.getSystemClipboard();
clipboard.setContents(stringSelection, null);
System.out.println("Clipboard is " + stringSelection);
wait.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")));
WebElement Paste = driver.findElement(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e"));
Actions builder = new Actions(driver);
//driver.findElement(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")).click();
wait.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")));
driver.findElement(By.id("ctl00_ContentPlaceHolder2_response_def06a4c-a2c3-4120-a165-7ed24d106c6e")).click();
builder.contextClick(Paste).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).perform();
I am also using firefox if that helps any.
Thank you!