Web ページの自動テスト ケースを作成しています。これが私のシナリオです。HTMLフォームでさまざまなWeb要素をクリックして入力する必要があります。しかし、テキストフィールドに入力しているときに、ajax の読み込みイメージが表示され、操作したいすべての要素がぼやけてしまうことがあります。したがって、以下のような実際の要素をクリックする前に、web-driver 待機を使用しています。
WebdriverWait innerwait=new WebDriverWait(driver,30);
innerwait.until(ExpectedConditions.elementToBeClickable(By.xpath(fieldID)));
driver.findelement(By.xpath(fieldID)).click();
しかし、wait 関数は、要素が別の画像によって覆われていてクリックできない場合でも、要素を返します。しかし、click() は次のように例外をスローします。
Element is not clickable at point (586.5, 278).
Other element would receive the click: <div>Loading image</div>
要素と対話する前に、読み込み中の画像が表示されたかどうかを毎回確認する必要がありますか? (読み込み中の画像がいつ表示され、すべての要素が曇るかは予測できません)。これを処理する効率的な方法はありますか? 現在、次の関数を使用して、読み込み中の画像が消えるまで待機していますが、
public void wait_for_ajax_loading() throws Exception
{
try{
Thread.sleep(2000);
if(selenium.isElementPresent("id=loadingPanel"))
while(selenium.isElementPresent("id=loadingPanel")&&selenium.isVisible("id=loadingPanel"))//wait till the loading screen disappears
{
Thread.sleep(2000);
System.out.println("Loading....");
}}
catch(Exception e){
Logger.logPrint("Exception in wait_for_ajax_loading() "+e);
Logger.failedReport(report, e);
driver.quit();
System.exit(0);
}
}
しかし、上記の関数をいつ呼び出すか正確にはわかりません。間違った時間に呼び出すと失敗します。要素が実際にクリック可能かどうかを確認する効率的な方法はありますか? またはローディング画像は存在しますか?
ありがとう..