【问题标题】:C# Selenium: Not able to get back to initail pageC# Selenium:无法返回初始页面
【发布时间】:2015-12-23 16:52:17
【问题描述】:

关于我之前的question,在 Iframe 模式关闭后,我无法返回初始页面。

我尝试使用

driver.SwitchTo().DefaultContent();
string currentWindow = driver.CurrentWindowHandle; //called before iframe modal popup window is called to open.
driver.SwitchTo().Window(currentWindow);

但未能这样做并收到错误:----> OpenQA.Selenium.StaleElementReferenceException : 在缓存中找不到元素 - 页面可能在查找后已更改。

预期结果:按钮应该被点击

实际结果:收到错误消息。

【问题讨论】:

    标签: c# selenium iframe automation


    【解决方案1】:

    问题已解决

    string currentWindow = driver.CurrentWindowHandle; 
    driver.SwitchTo().Window(currentWindow);
    driver.FindElement(By.XPath("@XpathLocation")).Click();
    

    它无法识别 Id 甚至类,所以我添加了 Xpath with calling curent window handler 并且它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-19
      • 1970-01-01
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 2021-08-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多