I have been attempting to access a search bar and submit the query without a SEARCH BUTTON. While I was able to enter the search query using javascriptexecutor, I encountered difficulty when trying to perform an Enter button action as there was no actual Enter button present. Consequently, I explored various approaches, but none proved successful. I humbly request your guidance in this matter.
My initial attempt involved executing an Enter key action on the search bar utilizing the following code:
driver.findElement(By.xpath("//*[@id='mobile-header']/div[3]/input")).sendKeys(Keys.RETURN);
and
WebElement search = bd.findElement(By.xpath("//*[@id='mobile-header']/div[3]/input"));
search.sendKeys(Keys.RETURN);
In the subsequent code snippet, although the value was successfully passed, the Enter key failed to function:
JavascriptExecutor jj= (JavascriptExecutor)bd;
jj.executeScript("arguments[0].value='mercury'", search);
jj.executeScript("arguments[0].value=Keys.Return", search);
Unfortunately, none of these methods seem to yield the desired outcome. Please correct me if my XPath is incorrect. Thank you for your assistance.