【问题标题】:Stale Element Exception, Element not Clickable,Element Click Intercepted & No Such Element error displayed Alternately by same element陈旧元素异常,元素不可点击,元素点击被拦截并且没有此类元素错误由同一元素交替显示
【发布时间】:2019-09-17 16:03:12
【问题描述】:

我正在尝试使用 Automation(Firefox) 选择 https://www.jabong.com/find/men's-black-jeans 中可用的多个文件管理器。

但是,在选择第一个选项(性别)后,我无法继续。

我遇到了 Element click 被拦截并尝试了 Fluent Wait 导致 Stale Element Exception。

如果我移除 Fluent 等待或使用隐式等待,我有时会收到 Element found 异常。

更令人困惑的是,有时代码无需等待即可正常运行,并且能够选择多个选项,但这种情况很少见

 public void case9() {
     driver.get("https://www.jabong.com/");
      WebElement SearchBox = driver.findElement(By.xpath("//*[@id=\"search\"]"));
      SearchBox.sendKeys("men's black jeans");
      Actions actn = new Actions (driver);
      actn.sendKeys(SearchBox, Keys.ENTER).build().perform();
      driver.manage().timeouts().implicitlyWait(34, TimeUnit.SECONDS);
      driver.findElement(By.xpath("//*[@id=\"allFilterPopupTop\"]")).click();
      driver.manage().timeouts().implicitlyWait(34, TimeUnit.SECONDS);
 driver.findElement(By.xpath("/html/body/section[1]/div/section/section[1]/div/div[2]/div[2]/ul/li[1]/div[3]/div/div[2]/label[1]/div/input")).click();


      driver.findElement(By.xpath("//*[@id=\"Brand\"]")).click();
      WebDriverWait wait1 = new WebDriverWait(driver,61);
      WebElement brand1 = 
      driver.findElement(By.xpath("xpath for element"));
      wait1.until(ExpectedConditions.elementToBeClickable(brand1));
      brand1.click();
      driver.findElement(By.xpath("xpath for element")).click();
      driver.findElement(By.xpath("//[@id=\"Global_Size\"]")).click();
      WebElement Size = 
      driver.findElement(By.xpath("xpath for element")); 
      wait1.until(ExpectedConditions.elementToBeClickable(Size));
      Size.click();
      driver.findElement(By.xpath("//*[@id=\"Fit\"]")).click();
      driver.manage().timeouts().implicitlyWait(61, TimeUnit.SECONDS);
      driver.findElement(By.xpath("xpath for element")).click();
      driver.findElement(By.xpath("//*[@id=\"Fade\"]")).click();
      driver.manage().timeouts().implicitlyWait(61, TimeUnit.SECONDS);    
      [@id=\"applyFIlters\"]")).click();
       }

【问题讨论】:

    标签: java selenium-webdriver testautomationfx


    【解决方案1】:

    我刚试过,这段代码运行良好。

    driver.get("https://www.jabong.com/");
            WebElement searchBox = driver.findElement(By.cssSelector("#search"));
            searchBox.sendKeys("men's black jeans");
            WebElement searchIcon = driver.findElement(By.cssSelector("#top-search-input > div.search-containter > span"));
            searchIcon.click();
            WebElement firstCheckBox = driver.findElement(By.id("boys"));
            firstCheckBox.click();
    

    【讨论】:

    • 感谢您回复@Arun Nair,选择性别不是问题。请尝试从所有/大部分类别中选择一些选项,然后应用过滤器。在至少 5-6 个类别中选择
    • 前品牌、尺码、褪色、腰围等
    猜你喜欢
    • 2020-08-07
    • 2020-01-04
    • 2021-10-28
    • 2022-11-13
    • 1970-01-01
    • 2021-09-04
    • 2021-07-08
    • 2021-10-08
    • 2019-09-24
    相关资源
    最近更新 更多