超时30秒后,等待

问题描述:

位于元素的存在我的下面的代码工作正常,但现在,我得到超时响应。我不确定如何处理这个超时问题 - 请告知。超时30秒后,等待

public void Browse_Samsung() throws Exception 
    { 
     WebDriverWait wait = new WebDriverWait(driver, 30); 
     Actions act = new Actions(driver); 
     act.moveToElement(Digital_Menu).perform(); 
     act.click(wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='CategoryMenu1']//a[@title='Samsung']")))).build().perform(); 

     WebElement Micromax = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='filter_1Option_21']//a[@title='GSM Mobile Phones - Micromax']"))); 

     JavascriptExecutor js = (JavascriptExecutor)driver; 
     js.executeScript("arguments[0].scrollIntoView(true);arguments[0].click()", Micromax); 

    } 
} 

场景:

  1. 登录www.homeshop18.com
  2. 从左边 显示在 “品牌” 一节 “数字” 菜单现在
  3. 选择 “三星”我需要SCROLL并选择另一个名为“Micromax”的品牌。

Error: org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for presence of element located by: By.xpath: //*[@id='filter_1Option_21']//a[@title='GSM Mobile Phones - Micromax']

+0

检查单击如果所有的定位器仍然有效。 – Guy

试试这个,这是完全工作我,我很能上“福邦”

Actions action = new Actions(driver); 

action.moveToElement(driver.findElement(By.linkText("Digital"))).build().perform(); 

WebDriverWait wait = new WebDriverWait(driver,30); 

wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Samsung"))); 

driver.findElement(By.linkText("Samsung")).click(); 

driver.findElement(By.xpath("//input[@class='input inputBox_filter_Brand']")).sendKeys("Micromax"); 

WebDriverWait wait1= new WebDriverWait(driver,30); 

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@title='GSM Mobile Phones - Micromax']"))); 

driver.findElement(By.xpath("//a[@title='GSM Mobile Phones - Micromax']")).click(); 

你有错的ID在你的XPath:

//*[@id='filter_1Option_21']//a[@title='GSM Mobile Phones - Micromax'] 

您应该使用filter_1Option_20但更好的使用XPath的:

//li/a[@title='GSM Mobile Phones - Micromax'] 

我觉得你的过滤器ID不是常数所以最好不要在xpath中使用ID。