user2377826:
私は私の旅作りのフィールドからで都市を選択するドロップダウン値をクリックしようとしていますhttp://www.makemytrip.com/を。しかし、古い要素参照の例外を取得。Idsは、ページの読み込みに変更してきています。コードの下にしようとしました:
driver.findElement(By.xpath(".//*[@id='hp-widget__sfrom']")).clear();
driver.findElement(By.xpath(".//*[@id='ui-id-1']"));
driver.findElement(By.xpath(".//*[@id='hp-widget__sfrom']")).click();
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeSelected(driver.findElement(By.xpath(".//*[@class='ui-menu-item'][2]"))));
DebanjanB:
ドロップダウン値などをクリックしてムンバイは、次のソリューションを使用することができます。
コードブロック:
driver.get("https://www.makemytrip.com/") new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='input_fromto checkSpecialCharacters ui-autocomplete-input' and @id='hp-widget__sfrom']"))).click(); List<WebElement> myList = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//li[@class='ui-menu-item'][starts-with(@id,'ui-id-')]//span[@class='autoCompleteItem__label']"))); for (WebElement element:myList) if(element.getText().contains("Mumbai")); element.click();
ブラウザスナップショット: