The problem here is that when you enter "source" from the dropdown and click on enter, the destination tabs get opened automatically.
Now when you try to hit the below code:
WebElement destination = driver.findElement(By.id("toCity"));
destination.sendKeys("Pak");
It wouldn't run because another element is on the top of
By.id("toCity"));
i.e By.xpath("//*[@placeholder='To']")
I try to click on that and got the following error:
Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <input data-cy="toCity" id="toCity" type="text" class="fsw_inputField lineHeight36 latoBlack font30" readonly="" value="Bangalore"> is not clickable at point (480, 255). Other element would receive the click:
<input type="text" autocomplete="off" aria-autocomplete="list" aria-controls="react-autowhatever-1" class="react-autosuggest__input react-autosuggest__input--open react-autosuggest__input--focused" placeholder="To" value="">
(Session info: chrome=91.0.4472.106)
Corrected Code: As per the current scenarios
///Code for Destination
WebElement suggestion2 = driver.findElement(By.xpath("//*[@placeholder='To']"));
suggestion2.sendKeys("Pak");
Thread.sleep(2000);
suggestion2.sendKeys(Keys.ARROW_DOWN);
suggestion2.sendKeys(Keys.ENTER);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…