セレンウェブドライバの簡単なスクリプトをjavaで選択してラジオボタンをクリックして作成しましたが、セカンドを選択してクリックすることはできませんWebページ上のラジオボタン 'ONE WAYのFLIGHT':http://www.lot.com/pl/en
セレンウェブドライバのラジオボタンを選択してクリックする方法
ここでは私のコードです:
WebDriver driver = new FirefoxDriver();
String web = "http://www.lot.com/pl/en";
driver.get(web);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
WebElement element;
element = driver.findElement(By.id("select2-departureAirport-container"));
element.click();
element.sendKeys("WAW");
element.sendKeys(Keys.ENTER);
/* RADIO BUTTON ERROR */
element = driver.findElement(By.cssSelector("input[value='SINGLE']"));
elementRadio.click();
そして、これは誤りです:
Exception in thread "main" org.openqa.selenium.ElementNotInteractableException:
そして、これはHTML Oの断片でありますn個のウェブページhttp://www.lot.com/pl/en
:
<div class="b-row">
<div class="b-column twelve">
<fieldset class="flight-type" role="radiogroup" aria-required="true">
<legend class="acc-hide">Choose flight type</legend>
<label class="booker-label radio-label">
<input data-f-focus="radio" id="ticketTypeReturn" type="radio" name="ticketType" class="required" value="RETURN" checked="checked" />
<span class="ci" aria-hidden="true"></span>
<span class="ci-label">Round-trip flight</span>
</label>
<label class="booker-label radio-label g-no-margin">
<input data-f-focus="radio" type="radio" name="ticketType" class="required" value="SINGLE" />
<span class="ci cis" aria-hidden="true"></span>
<span class="ci-label">One-way flight</span>
</label>
<p id="ticketTypeReturn--required" class="b-v-error" role="alert">Choose flight type</p>
</fieldset>
</div>
</div>
私はそれが例外をスローして理由を理解することができません。コードの下
同じエラースレッド "main"の例外org.openqa.selenium.ElementNotInteractableException – mvillegas
@mvillegas - 私はちょうど私の答えを更新しました。今すぐ試してみてください。 – Kapil
偉大な、うまく動作します。どうもありがとう – mvillegas