Challenge 6 selenium java

Một vài cách không chạy được:

  • Điền trực tiếp “Hanoi,Vietnam” vào thẻ input
  • Điền “Hanoi” rồi click vào cái ô suggestion bên dưới (element not interactable)

Đáp án:

  • Click vào ô City Name –> trang web sẽ tạo ra 1 thẻ input ở phía cuối của DOM.
  • Điền “Hanoi” vào thẻ input
  • Ấn Enter
driver.findElement(By.id("select2-hotels_city-container")).click();
Thread.sleep(2000);
driver.findElement(By.cssSelector("input.select2-search__field")).sendKeys("Hanoi");
Thread.sleep(2000);
driver.findElement(By.cssSelector("input.select2-search__field")).sendKeys(Keys.ENTER);

Ở giữa các step mình dùng Thread.sleep(), bạn có thể thay thế bằng Explicit Wait tương ứng.

5 1 vote
Đánh giá challenge
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
hung thần Java
hung thần Java
2 years ago
explicits.until(ExpectedConditions.visibilityOfElementLocated(getByXpath(getDynamicLocator(locator, values))));