リストの2番目のチェックボックスを選択しようとしているときにWebDriverExceptionが発生します。私は最初のチェックボックスを選択することができますが、2回目には例外をスローします。私が使用している方法と以下の例外メッセージを見つけてください。 注:ご提案は私にとって役に立ちます。2番目のチェックボックスをチェックできません。 org.openqa.selenium.WebDriverExceptionを取得しています:不明なエラー:要素がポイント(106,665)でクリック可能でない
URL:https://www.snapdeal.com/products/computers-external-hard-drives?sort=plrty&q=Capacity_s%3A1%20TB%7C
public void capacitySelection(String capacity){
WebDriverWait wd = new WebDriverWait(driver, 180);
List<WebElement> cList = wd.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@data-name='Capacity_s']/div")));
int i=1;
for(WebElement we:cList){
WebElement select= wd.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@data-name='Capacity_s']/div["+ i++ +"]/label")));
if(select.getText().contains(capacity)){
select.click();
break;
}
}
}
Exception Message:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (106, 655). Other element would receive the click: <label for="Capacity_s-3TB">...</label>
(Session info: chrome=54.0.2840.99)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.2.9200 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 86 milliseconds
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Bishnu', ip: '192.168.0.107', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\Bishnu\AppData\Local\Temp\scoped_dir11044_5076}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.99, platform=WIN8, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 505ec9fb429bc6b9806edb52d75856f0
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at in.prolearn.pages.HomePage.SecondCapacitySelection(HomePage.java:59)
at in.prolearn.testcases.VerifySnapDealSelection.main(VerifySnapDealSelection.java:22)
感謝。
今、私はorg.openqa.selenium.StaleElementReferenceExceptionを取得しています。また、最初の項目が選択されると、Htmlの変更が表示されます。上記のURLを使用して、1 TBと2 TBの容量チェックボックスを選択してください。 –
最初の項目を選択した後にhtmlの変更がある場合は、最初の選択の後に2番目のチェックボックスを配置する必要があります。あなたのコードでは、最初のチェックボックスを選択する前でも、すべてのWeb要素を選択してリストに格納しています。それがStaleElementReferenceExceptionを取得する理由です。 – CARE
こんにちは、貴重なご意見ありがとうございます。上記のメソッドが表示されたら、チェックボックスを選択しようとしたときにmain()から呼び出しています。このメソッドを呼び出すたびに、その特定のチェックボックスだけが選択されます。上記のメソッドを呼び出して2番目のチェックボックスを選択すると、すべてのWeb要素が検索され、変数にもう一度格納されます。あなたが少し時間があるなら、あなたは上記のURLを開いて、あなたが私を同じように助けることができるかどうかを見ることができます。再度ありがとう –