Home > other >  Xpath element not interractable issue. Selenium,Java
Xpath element not interractable issue. Selenium,Java

Time:04-01

I have been trying to access a search bar and submit the query which doesnot have a SEARCH BUTTON, as I Could enter the search query using javascriptexecutor, I Couldnot do an enter button action as It doesnot have any enter button. so I have went with the following ways and none of them worked. Please consider and correct me.

I have tried to do an enter key action on the search bar. the code is as followed 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);

and `in the following code the value is passed but the enter key is not working JavascriptExecutor jj= (JavascriptExecutor)bd; jj.executeScript("arguments[0].value='mercury'", search); jj.executeScript("arguments[0].value=Keys.Return", search);

none of the seems to work. correct if i have my xpath wrong. thanks

CodePudding user response:

This should work:

    driver.findElement(By.xpath("//*[@class='st-search-box hidden-mobile-only']//input[@type='text']").sendKeys("headphones);
    ActionChains(driver).sendKeys(Keys.RETURN)
  • Related