私はwebelementsのリストを持っています。このリストをforeachループで繰り返し、webelementをクリックするとループし、1つの画面から2番目の画面に切り替わります。私の仕事私はボタンを押して、再びwebelementsのリストを持っている最初の画面に戻ります。この全体のシナリオは、最初の反復のためにだけ働くが、2回目の反復では、このような例外を取得し、スイッチングウィンドウがセレニウムwebelementのJavaで動作しません
「org.openqa.selenium.StaleElementReferenceExceptionされます。要素がキャッシュに見つかりません - それは見えたので、おそらく、ページが変更されました コマンド期間またはタイムアウトまで:50.13秒」
後、私のコードは、ある
try { /** * In this scenario i am iterating through webelementlist, in first iteration i have clicked first * webelement, then fetching some values from second screen after doing my work returning back * to the first one. */ List<WebElement> elementList = driver.findElements(By.className("classname")); for(WebElement webElement: elementList){ webElement.click(); //fetching some values String str = driver.findElement(By.className("classname")).getText(); System.out.println("Value : "+str); //returning back to the first page driver.findElement(By.xpath(".//*[@id='pane']/div/div[1]/div/button")).click(); } } catch (Exception e) { e.printStackTrace(); }
は長い間それに取り組んでいますが、解決策が得られていません。