dongmingxiang0312 2014-12-04 02:46
浏览 18

如何在Selenium(或Firefox IDE)中选择/获取HIDDEN下拉选项

I think that I may be asking something that has been answered, But I really can't tell. (a-hem) Here's my problem (This is an example... my site is behind a login) Go to www.humana.com. Hover over the text "Insurance Through Your Employer >" You will note that it was "hiding" more options... (But is not a classic dropdown menu) Say, I want to test the products-and-services function (not the actual page, but how this menu works.... no fair dodging the Q (grin)) If I try "clickAndWait" with "link=products-and-services" I get an error, because the test tool can't "see" the element.... (PHPUnit user, if it helps)

Is there a way to have the "mouse" "Hover" over element "A", and then, "Select/Click" on Element "B"?

  • 写回答

1条回答 默认 最新

  • doulangtiao4508 2016-03-02 10:26
    关注

    To answer your question as it was mentioned in the title:

    In your browser, open the drop-down, while the inspector is ON, click on one of its elements so that you will be guided to the right section of the HTML code. You should be directed to a set of ul, li tags. Having the XPath found in this way, a single command like the example below should serve the goal:

    command:

    clickAt
    

    Target:

    //ul[@id='select-area-map-menu']/li[2]
    

    To answer your hover and click question:

    Use clickAt command in the same way (but NOT for the select tag). For instance:

    clickAt   |  //a[@id='button-id']  | 
    

    This will click on a drop-down as if a user cliked on it to open. You can use many commands to trigger many actions then. For instance, mouseDown command to click. However I think the first part of my answer is enough if the problem is that the drop-down was hidden.

    I was dragged here by google since I had the same question. I am not an expert but I hope this answer works for others just fine.

    评论

报告相同问题?

悬赏问题

  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 YOLOv8obb获取边框坐标时报错AttributeError: 'NoneType' object has no attribute 'xywhr'