Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 无法从下拉列表中单击列表元素_Ruby_Selenium_Selenium Webdriver - Fatal编程技术网

Ruby 无法从下拉列表中单击列表元素

Ruby 无法从下拉列表中单击列表元素,ruby,selenium,selenium-webdriver,Ruby,Selenium,Selenium Webdriver,使用Selenium WebDriver,我尝试单击测试中的手动测试菜单中的手动测试选项,然后将鼠标悬停在测试上。为了实现上述目标,我做了以下工作: testing = $driver.find_element(:xpath, "//li[@class='item118 parent']") mt = $driver.find_element(:xpath, "//li[@class='item119']/a") $driver.action.move_to(testing).move_to(

使用Selenium WebDriver,我尝试单击
测试中的
手动测试
菜单中的
手动测试
选项,然后将鼠标悬停在
测试
上。为了实现上述目标,我做了以下工作:

testing = $driver.find_element(:xpath, "//li[@class='item118 parent']")
mt = $driver.find_element(:xpath, "//li[@class='item119']/a")

$driver.action.move_to(testing).move_to(mt).perform
mt.click
但是,上面代码第3行有时会出错-

Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Offset within element ca
nnot be scrolled into view: (85, 21): http://guru99.com/software-testing.html
Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently vis
ible and so may not be interacted with
在上面的代码中,第4行有时会出错-

Selenium::WebDriver::Error::MoveTargetOutOfBoundsError: Offset within element ca
nnot be scrolled into view: (85, 21): http://guru99.com/software-testing.html
Selenium::WebDriver::Error::ElementNotVisibleError: Element is not currently vis
ible and so may not be interacted with
请帮助我在不执行javascript的情况下解决此问题

下面是HTML代码-

<li class="item118 parent">
  <a class="item" href="/software-testing.html"> Testing </a>
   <span class="dropdown-spacer"></span>
 <div class="dropdown columns-1 " style="width:180px;">
   <div class="column col1" style="width:180px;">
     <ul class="l2">
       <li class="item119">
         <a class="item" href="/software-testing.html"> Manual Testing </a>
      </li>
     .
     .
     .
    • . . .
  • 您可以尝试使用
    部分链接文本

    testing = $driver.find_element(:partial_link_text, "Testing")
    $driver.action.move_to(testing).perform
    mt = $driver.find_element(:partial_link_text, "Manual Testing")
    mt.click
    

    如果可能,请发布您的HTML代码片段使用HTML代码片段更新问题。这不是像-
    无法定位元素这样的问题
    我提到的元素已找到,但无法从下拉列表中选择列表元素。我不是说您搜索的元素不存在,但是,这真的是需要的吗?……例如,考虑<代码>红色按钮<代码> >代码>方框,要求是按<代码>红色按钮< /代码>,而不是在方框的顶面……在你的情况下,Li就像方方块,Akor标签就像红色按钮。我试过了,但它给出了错误
    无法定位
    mt=$driver的元素
    。查找元素(:partial\u link\u text,“手动测试”)
    我不明白,为什么在它正确之前发生这种情况?仍然,
    无法定位
    手动测试
    链接的元素。我通常使用java,JavaScriptexecutor在这种情况下是否会派上用场,但ruby不确定。。