次のフォームの[ 件名]フィールドの値を選択しようとしています。https://demoqa.com/automation-practice-form
これは、入力に基づいて動的に提案を行う入力フィールドであり、後でこれらの提案から値を選択する必要があります。希望の値を選択できません。
以下のコードは入力領域のみに入力しますが、値は選択されていません。
driver.findElement(By.id("subjectsInput")).sendKeys("English");
driver.findElement(By.id("subjectsInput")).click(); //This line doesnot click on the desired value.
希望の値を選択する方法。助けてください。
だけでクリックを起動するには、自動提案 英語あなたが誘導する必要がWebDriverWaitをするためにelementToBeClickable()
、あなたは、次のいずれかを使用することができロケータ戦略:
cssSelector
:
driver.get("https://demoqa.com/automation-practice-form");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#subjectsInput"))).sendKeys("English");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.subjects-auto-complete__menu"))).click();
xpath
:
driver.get("https://demoqa.com/automation-practice-form");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='subjectsInput']"))).sendKeys("English");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[contains(@class, 'subjects-auto-complete__menu')]"))).click();
ブラウザのスナップショット:
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加