zoukankan      html  css  js  c++  java
  • selenium webdriver使用过程中出现Element is not currently visible and so may not be interacted with的处理方法

    参考文章:

    http://blog.csdn.net/passionboyxie/article/details/28661107

    http://www.spasvo.com/ceshi/open/kygncsgj/Selenium/2014324160758.html

    因为我遇到的问题是下拉菜单的遇到的,因此第二篇文章是关于下拉菜单的,问题的原因是下拉菜单的属性style="display:none;"解决办法是参照第一篇文章,使用javascript修改这个属性为block,然后再操作这个元素就可以了,修改属性的代码如下:

    IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor) driver;
    javaScriptExecutor.ExecuteScript("document.getElementById('jq-company-dropdown').style.display='block';");

    操作元素的代码如下:主要是选中下拉菜单中的一个选项

    driver.FindElement(By.Id("jq-company-dropdown")).FindElement(By.XPath("//option[@value='1']")).Click();

  • 相关阅读:
    Remove Linked List Elements
    Count Primes
    Isomorphic Strings
    Read N Characters Given Read4 II
    Word Ladder II Graph
    Word Ladder
    Binary Tree Right Side View
    House Robber
    Find non-overlap jobs with max cost
    Find Peak Element
  • 原文地址:https://www.cnblogs.com/techfans/p/4329398.html
Copyright © 2011-2022 走看看