0

以前の操作オプション ID の html ファイルから取得し、それらをリストに格納します。

次に、リストの各メンバーについて、次のページを開くようにしてください: www.xxx.xxx/en/account/service/SERVICEID

最初に有効な要素ページが開かれますが、ブラウザはアクティビティを停止します...そして私はこれを取得します

org.openqa.selenium.StaleElementReferenceException: 要素がキャッシュに見つかりません - おそらくページが検索されてから変更されました コマンドの実行時間またはタイムアウト: 3.28 秒

   public class testy2{
private WebDriver driver;
private String baseUrl;
private List<WebElement> serviceList;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();

@BeforeClass
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "https://www.fastgsm.com";

   // driver.manage().timeouts().pageLoadTimeout(120,TimeUnit.SECONDS);


}

@Test
public void test() throws Exception {
    //Open page and set up login
    driver.get(baseUrl + "/en/account/login");
    driver.findElement(By.id("login")).clear();
    driver.findElement(By.id("login")).sendKeys("selenium@account");
    driver.findElement(By.id("password")).clear();
    driver.findElement(By.id("password")).sendKeys("1Selenium");
    driver.findElement(By.id("password")).submit();


    serviceList = driver.findElements(By.xpath("//select[@name='token_id']/option"));


    for (WebElement service : serviceList) {

        if(!service.getAttribute("value").contains("-")){
        String test = service.getAttribute("value");
        System.out.println("Checking service name : " + service.getAttribute("value") + ",on page " + (baseUrl + "/en/account/service/"+service.getAttribute("value")) );

        driver.get(baseUrl + "/en/account/service/"+test);

        System.out.println("Service name : " + service.getAttribute("value") +"status : OK");

        }
        else{
        System.out.println("ERROR : INVALID SERVICE NAME");
        }
    }


}
4

1 に答える 1