Home > Back-end >  How to input search arrow down and press enter in selenium
How to input search arrow down and press enter in selenium

Time:09-17

Please help. I tried so much but it did not work thank you

System.setProperty("Webdriver.chrome.drive", "C\\chromedrivers.exe");

String baseUrl = "https://freshii.tacitdev.ca/";

ChromeDriver driver = new ChromeDriver();

driver.get(baseUrl);

driver.manage().window().maximize(); 

driver.findElement(By.xpath("//span[contains(text(),'Locations')]")).click();

driver.navigate().to("https://freshii.tacitdev.ca/ca/lang/en/locations/delivery");

driver.findElement(By.xpath("//body/app-root[1]/ng-component[1]/div[1]/main[1]/ng-component[1]/ng-component[1]/div[1]/div[1]/div[1]/div[1]/autocomplete-manual[1]/div[1]/input[1]")).sendKeys("175 Hilda Avenue, North York, ON, Canada"   Keys.ENTER);

CodePudding user response:

Maybe you lose the focus on the element, try this

WebElement input = driver.findElement(By.cssSelector("input[aria-label='AddressSearch']"));
input.sendKeys("175 Hilda Avenue, North York, ON, Canada");
input.click();
Thread.sleep(1000);
input.sendKeys(Keys.RETURN);
  • Related