【问题标题】:Locating ASP Sitemap tree structures child nodes using Selenium webdriver使用 Selenium webdriver 定位 ASP Sitemap 树结构子节点
【发布时间】:2012-04-06 08:52:31
【问题描述】:

我尝试自动化的网站可以通过使用站点地图树进行导航。现在为了从 selenium 访问子节点,我编写了以下代码:

IWebElement menu = driver.FindElement(By.LinkText("Setup"));
//Setup is the parent node
Actions mouseOver = new Actions(driver);
mouseOver.MoveToElement(menu).Build().Perform();
driver.FindElement(By.LinkText("Entities")).Click();
//Entities is the child node.

但是 webdriver 会抛出 Element not found 异常。

我正在使用 Firefox 来播放测试用例。

【问题讨论】:

  • 经典 asp 不是 ASP.NET,C# 从来都不是它的选择。请使用正确的标签。

标签: c# selenium webdriver sitemap


【解决方案1】:

也许您等待元素出现的时间不够长,这就是“找不到元素”的原因。你试过 WebdriverWait 吗?

IWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
IWebElement menu = driver.FindElement(By.LinkText("Setup"));
Actions mouseOver = new Actions(driver);
mouseOver.MoveToElement(menu).Build().Perform();
IWebElement entities = 
wait.Until(ExpectedConditions.ElementExists(By.LinkText("Entities"))); 
entities.click();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-12
    • 1970-01-01
    • 2015-05-15
    • 2010-11-29
    • 2012-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多