【问题标题】:Locating dropdown box using Selenium webdriver使用 Selenium webdriver 定位下拉框
【发布时间】:2014-08-25 07:44:59
【问题描述】:

我正在尝试在 selenium webdriver 中使用 C# 定位下拉框。尝试了不同的 By.Id、By.XPath 等选项,但无法定位元素。下面是 HTML 代码 一样的。

<div class="chzn-drop" style="left: -9000px; width: 387px; top: 32px;">
<div class="chzn-search">
    <input type="text" autocomplete="off" style="width: 352px;" tabindex="5">
</div>
<div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto;">
    <ul class="chzn-results" style="overflow: hidden; width: auto;">
    <div class="slimScrollBar" style="background: none repeat scroll 0% 0% rgb(0, 0, 0);  width: 15px; position: absolute; top: 0px; opacity: 0.4; display: block; border-radius: 7px; z-index: 99; right: 1px; height: 121.263px;"></div>
        <div class="slimScrollRail" style="width: 15px; height: 100%; position: absolute; top: 0px; display: block; border-radius: 7px; background: none repeat scroll 0% 0% rgb(51, 51, 51); opacity: 0.2; z-index: 90; right: 1px;"></div>
    </div>
</div>

【问题讨论】:

  • 你尝试过哪些 xpath 表达式?
  • 请发布您尝试过的代码。

标签: c# selenium-webdriver


【解决方案1】:

试试 By.Css,例如

driver.find(By.Css(".slimScrollDiv"));

【讨论】:

    猜你喜欢
    • 2011-11-06
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    • 2014-05-29
    • 1970-01-01
    相关资源
    最近更新 更多