help to perform Sendkeys (Enter) from keyboard after passing the text in Text field

91 views
Skip to first unread message

Narayan Bulchandani

unread,
Nov 20, 2019, 11:23:51 PM11/20/19
to Selenium Users
Hi Selenium Group Team

I need help in following context: I have a test scenario, in which There is a text field on the web page, The field is called Search text field. In the Search Field I need to enter a searchtext and then need to click the Enter key from Keyboard.
I have tried to locate the element by following method:

WebElement SearchBox;
SearchBox = driver.findElement(By.xpath("//input[@title='Search Salesforce']"));
Actions actions = new Actions(driver);
  actions.sendKeys(SearchBox, "Hospital").keyUp(Keys.CONTROL).perform();

Also I tried this one 

WebElement Search = driver.findElement(By.xpath("//input[@title='Search Salesforce']"));
Search.sendKeys("Hospital");
Search.sendKeys(Keys.Enter);


After performing this The Search Field get blank and  expected Search results does not appear.


Here is html script of the webElement

<input class="slds-input slds-text-color_default slds-p-left--none slds-size--1-of-1 input default uiInput uiInputTextForAutocomplete uiInput--{remove}" maxlength="100" role="combobox" id="159:0;p" aria-expanded="true" aria-autocomplete="list" type="text" aria-describedby="" aria-haspopup="true" placeholder="Search Salesforce" aria-activedescendant="" title="Search Salesforce" data-aura-rendered-by="183:0;p" data-aura-class="uiInput uiInputTextForAutocomplete uiInput--{remove}" data-interactive-lib-uid="2" autocomplete="off" spellcheck="false" keepfocusonnavigate="true">

I will Thankful for your reply..

Thank You
Narayan Boolchandani

Aditya Sisodiya

unread,
Nov 20, 2019, 11:45:40 PM11/20/19
to seleniu...@googlegroups.com
driver.findElememt(By.xpath("xpath of input field")).sendKeys("message"); 
driver.findElement(By.xpath("xpath of button")).click();

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/4ed08362-bb21-475e-aca9-c35f524551eb%40googlegroups.com.

mahesh harish

unread,
Nov 21, 2019, 9:08:53 PM11/21/19
to seleniu...@googlegroups.com
Hi , 

WebElement SearchBox;
SearchBox = driver.findElement(By.xpath("//input[@title='Search Salesforce']"));
Actions actions = new Actions(driver);
  actions.sendKeys(SearchBox, "Hospital",Keys.Enter ); 

Try this one  it will be heip you .
Thanks
Mahesh G 



On Thu, Nov 21, 2019, 9:53 AM Narayan Bulchandani <naray...@gmail.com> wrote:
--

Narayan Bulchandani

unread,
Nov 26, 2019, 3:22:39 AM11/26/19
to seleniu...@googlegroups.com
Thank You Aditya, but it did not worked.

Koh Jun De

unread,
Nov 26, 2019, 4:20:43 AM11/26/19
to seleniu...@googlegroups.com
Hi Narayan, try this : 

WebElement Search = driver.findElement(By.xpath("//input[@title='Search Salesforce']"));
Search.sendKeys("Hospital");

Actions actions = new Actions(driver);
actions.sendKeys(Keys.Enter);
actions.perform();

Regards,
Jayven



--

Aditya Sisodiya

unread,
Nov 26, 2019, 7:59:53 AM11/26/19
to seleniu...@googlegroups.com
WebElement SearchBox = driver.findElement(By.xpath("//input[@title='Search Salesforce']"));  
  SearchBox.sendKeys("message",Keys.ENTER) ;

rishal singh shekhawat

unread,
Nov 27, 2019, 6:36:57 AM11/27/19
to seleniu...@googlegroups.com
Hey Narayan,

Can you try this it will work for you.

 Thread.sleep(15000);
        WebElement element = driver.findElement(By.xpath("//input[@placeholder='Search Salesforce']"));
        element.sendKeys("THE CHRIST HOSPITAL");
        element.sendKeys(Keys.ENTER);

Thanks,
Rishal Singh

--
Reply all
Reply to author
Forward
0 new messages