Firefox Click操作无法正常运行

时间:2014-01-06 23:56:28

标签: c# html selenium-webdriver

我对IWebElement.Click()提出了一个问题,该问题对指定区域href无效。 该网页有大约20个具有相同结构的项目:

<area alt="0" shape="circle" coords="190,88,28" href="build.php?id=1">
<area alt="1" shape="circle" coords="280,89,28" href="build.php?id=2">
<area alt="2" shape="circle" coords="348,101,28" href="build.php?id=3">
<area alt="3" shape="circle" coords="132,127,28" href="build.php?id=4">
<area alt="4" shape="circle" coords="245,140,28" href="build.php?id=5">
<area alt="5" shape="circle" coords="302,147,28" href="build.php?id=6">
<area alt="6" shape="circle" coords="387,145,28" href="build.php?id=7">
<area alt="7" shape="circle" coords="72,178,28" href="build.php?id=8">

还有更多的。 当我访问<area href="build.php?id=5">时,.Click动作似乎已执行,但没有任何操作,导致后续代码崩溃。 这是我的C#代码,用于访问id = 5的区域:

    String URL = "map area[href=\"build.php?id=" + id + "\"]";
    element = wait.Until<IWebElement>((d) => { returnd.FindElement(By.CssSelector(URL)); });

    if (element != null)
    {       
       element.Click();
       element = wait.Until<IWebElement>((d) => { return d.FindElement(By.CssSelector(button)); });
    }

对于每个区域,除了区域为href $ =“id = 5”的区域外,这都有效。该元素不为null,因此执行element.Click()时没有任何异常,稍后我得到了waitexception,因为页面没有加载,并且从未通过单击ID = 5加载。

我尝试使用他们的上DIV,UL,LI等指定更多区域,而没有任何解决此问题的方法。

我得到了一个解决方案:

    driver.Navigate().GoToURL("*/build.php?id=5");

但有时driver.Navigate()。GoToURL()会打开新窗口或浏览器选项卡(可能是某些类型驱动程序配置的超时?)。

注意:我尝试使用selenium id访问该元素,没有任何问题。

0 个答案:

没有答案
相关问题