Struggling to use WebDriver sendKeys() function to input text in a text field
View the HTML below:
<table class="gridtable" cellspacing="0" __gwtcellbasedwidgetimpldispatchingfocus="true" gwtcellbasedwidgetimpldispatchingblur="true" style="width: 100%;">
<thead>
<colgroup>
<tbody style="">
<tr class="GORM0XEDKD GORM0XEDME" onclick="">
<td class="GORM0XEDJD GORM0XEDLD GORM0XEDMD GORM0XEDNE">
<td class="GORM0XEDJD GORM0XEDLD GORM0XEDNE GORM0XEDGE">
<div style="outline:none;" tabindex="0"></div>
</td>
</tr>
</tbody>
<tbody style="display: none;">
<tfoot style="display: none;">
</table>
XPath for the text field -
EmailTemplateEditorTemplateName= By.xpath("//*[contains(@class,'GORM0XEDJD GORM0XEDLD GORM0XEDNE GORM0XEDGE')]/div[1]");
We attempted the following options, all unsuccessful in entering text into the EmailTemplateEditorTemplateName text field
1. driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName).sendKeys("yahooo"); 2. this.WaitForElement(DesignerLocators.EmailTemplateEditorTemplateName); WebElement tempname = driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName); JavascriptExecutor rightexecutor = (JavascriptExecutor)driver; rightexecutor.executeScript("arguments[0].setAttribute('value','yahoo')", tempname); 3. WebElement Element=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName); Actions builder = new Actions(driver); builder.moveToElement(Element).sendKeys("yahoo").build().perform(); 4. WebElement Element=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName); Actions builder = new Actions(driver); builder.moveToElement(Element).click().sendKeys("yahoo").build().perform(); 5. WebElement Element=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName); Actions builder = new Actions(driver); builder.moveToElement(Element).click(Element).sendKeys("yahoo").build().perform();
The click() method is functioning correctly.
- The getText() method surprisingly works for the same text field using the same XPath. String val=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName).getText();
- Only sendKeys() seems to be nonfunctional without any error being thrown.
- Please provide assistance in inputting text into my text field.