2017-01-06 7 views
0

私のセレンのコードを参考にしてください。私はちょうど初心者で、私のコードに何が間違っているのか理解できません。エラーメッセージ:org.openqa.selenium.ElementNotVisibleException:要素が表示されない(セッション情報:chrome = 55.0.2883.87)

アコーディオンの下向き矢印がクリックされました。 時間が見つかりました。 FAILED:homeLoan( "Janet Jones"、 "[email protected]"、 "Australia"、 "4569"、 "62365898563"、 "Home Loan"、 "Buying"、 "150000"、 "55000") org.openqa.selenium.ElementNotVisibleException:要素が表示されない (セッション情報:chrome = 55.0.2883.87) (ドライバ情報:chromedriver = 2.25.426923(0390b88869384d6eb0d5d09729679f934aab9eed)、プラットフォーム= Windows NT 10.0.14393 x86_64)(警告:サーバースタックトレース情報を提供していません) コマンドの継続時間またはタイムアウト:25ミリ秒 ビルド情報:バージョン: '2.53.1'、リビジョン: 'a36b8b1cd5757287168e54b817830adce9b0158d'、時刻:'2016-06-30 19:26:09 ' システム情報:ホスト: 'DEV-TEST-01'、ip: '172.30.60.20'、os.name: 'Windows NT(不明)'、os.arch: 'amd64'、os.version:'10 .0 '、java.version : '1.8.0_112' ドライバーi nfo:org.openqa.selenium.chrome.ChromeDriver 機能[{applicationCacheEnabled = false、rotatable = false、mobileEmulationEnabled = false、networkConnectionEnabled = false、chrome = {chromedriverVersion = 2.25.426923(0390b88869384d6eb0d5d09729679f934aab9eed)、userDataDir = C:\ Users \あなたは、あなたのサイトにアクセスするために必要なすべての情報を取得する必要があります。 =真= locationContextEnabled、真= acceptSslCerts、真、真= webStorageEnabled、browserName =クロム、takesScreenshot =真、javascriptEnabled =真、cssSelectorsEnabled =真}] セッションID:

私のコードをeba36d4b2bcab09b464da0fbf99e681dの下矢印をクリックすることができますアコーデオン、そしてまたセチェックボックスがついています。しかし、私のコードは優先時間のそのチェックボックスをクリックすることはできません。

System.out.println("Switched to pop up window."); 

driver.findElement(By.xpath("//*[@id='modalBookAppointment']/div/div/div/h4")); 
System.out.println("When would you like us to call you? found."); 

driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); 
driver.findElement(By.xpath("(//*[@class='fa fa-chevron-down'])[3]")).click(); 
System.out.println("Accordion down arrow clicked."); 

driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); 

driver.findElement(By.xpath("//*[@id='p_lt_ctl00_Firstmac_RetailHardSellBookAppointment_BookAppointment_AppointmentDatesRepeater_ctl01_BookAppointment_AppointmentsRepeater_ctl12_AppointmentSelection_Vacant']/div[1]/input")); 
System.out.println("Time found."); 

driver.findElement(By.xpath("//*[@id='p_lt_ctl00_Firstmac_RetailHardSellBookAppointment_BookAppointment_AppointmentDatesRepeater_ctl01_BookAppointment_AppointmentsRepeater_ctl12_AppointmentSelection_Vacant']/div[1]/input")).click();; 
System.out.println("Time selected."); 

私はスクリーンショットから最初にハイライトされた朝9時を選択しようとしています。

enter image description here

すべてのヘルプが行います。前もって感謝します。

+0

私は使用されたXPathが有効ではないと思います。 – n247s

+0

「見つかった時間」が表示されます。それはエラーが発生しています。クリック(); –

+0

要素が見えるかもしれないが、その要素はクリック可能ではないかもしれない、私の答えをチェックし、その正しい – n247s

答えて

0

私の問題は、あなたのxpathが正しくないと思います。あなたのものはinputタグを指していますが、thr immageの部分はその直前のdiv要素を指しています。

投稿した画像には、 'firePath'タブの上部に完全な正しいパスが表示されます。代わりにそれを使用して、それがうまくいったらお知らせください。

編集: 時間を基準にしているかどうかを確認するには、次の方法を試すことができます。

WebDriverWait wait = new WebDriverWait(driver, 15); 
wait.until(ExpectedConditions.elementToBeClickable(yourXPath)); 
+0

お返事ありがとうございます。アコーディオン内部のチェックボックスのXPathです:// */divの[ID =「p_lt_ctl00_Firstmac_RetailHardSellBookAppointment_BookAppointment_AppointmentDatesRepeater_ctl01_BookAppointment_AppointmentsRepeater_ctl03_AppointmentSelection_Vacant」@] [1] /入力 –

+0

イムは、それがSTIL​​私に同じエラー –

+0

になりました/入力せずに1をしよう私は自分の答えを編集しました。これがあなたの問題を解決したかどうかを見てください。 –

0

ターゲット要素が目に見えるようになるまで、いくつかの時間を待つようにしてください:

JavascriptExecutor js = (JavascriptExecutor) driver; 
js.executeScript('document.querySelector("input[type='checkbox']").style.display="block";'); 

WebDriverWait wait = new WebDriverWait(driver, 10); 
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@type='checkbox']"))); 
+0

これを試してもまだ動作していません。エラー:org.openqa.selenium.TimeoutException:期待される条件に失敗しました:By.xpathによって位置決め要素の可視性を待っている://入力[@タイプ=「チェックボックス」(500ミリ秒間隔で15秒(S)のための試み) –

+0

更新された回答を試す – Andersson

0

私はすでに// * XPathを変更することでこの問題を解決してきた[ID @ = 'p_lt_ctl00_Firstmac_RetailHardSellBookAppointment_BookAppointment_AppointmentDatesRepeater_ctl01_BookAppointment_AppointmentsRepeater_ctl12_AppointmentSelection_Vacant']

関連する問題