0

I am passing sendKeys( ) through search grid to search a particular string.I am able to click that search text but its not clicking the search string ,Below is the html for that search text:

<input  name="ctl00$ContentPlaceHolder1$txtSessionName"
        type="text"
        onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$txtSessionName\',\'\')', 0)"
        onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;"
        id="ContentPlaceHolder1_txtSessionName"
        class="search-icon"
        placeholder="Session Title/Track Name"
        onkeyup="ShowSearch();"
        title="Session Name"
        autocomplete="off"
        style="width: 300px;">

I used with below code but not working:

First try

driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtSessionName").sendKeys(searchSessionText);

Second try

WebELment= driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtSessionName"));
JavascriptExecutor rightexecutor = (JavascriptExecutor)driver;
rightexecutor.executeScript("arguments[0].setAttribute('value','searchSessionText')", Element);

Third try:

WebElement
Element=driver.findElement(By.name("ctl00$ContentPlaceHolder1$txtSessionName"));
Actions builder = new Actions(driver);
builder.moveToElement(Element).sendKeys(searchSessionText).build().perform();

Fourth try:

WebElement
Element=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName);
Actions builder = new Actions(driver);
builder.moveToElement(Element).click().sendKeys(searchSessionText).build().perform();

Fifth try

WebElement Element=driver.findElement(DesignerLocators.EmailTemplateEditorTemplateName);
Actions builder = new Actions(driver);
builder.moveToElement(Element).click(Element).sendKeys(searchSessionText).build().perform();

Please suggest.

  • Is this for a auto-complete in the search box? – demouser123 Aug 7 '15 at 10:29
  • yes this is for autocomplete text box .you can see html snippet on top. – Ranjan Gupta Aug 7 '15 at 10:34
  • I think the auto complete is not displaying for enough time to send the click event. Try adding a Key down after sending the search string and then click. – demouser123 Aug 7 '15 at 10:40
  • You can see this answer. sqa.stackexchange.com/questions/13578/… – demouser123 Aug 7 '15 at 10:42
  • I used what ever stated in above link but still its not working for me . – Ranjan Gupta Aug 7 '15 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.