【问题标题】:Selection of specific value from dropdown从下拉列表中选择特定值
【发布时间】:2014-10-03 23:37:42
【问题描述】:

我正在尝试传递国家/地区的特定值以从下拉列表中选择 但我无法使用以下代码:

wd.FindElement(By.Id("CountrySelector")).Click(); 
new SelectElement(wd.FindElement(By.Id("CountrySelector"))).SelectByText("Philippines-Philippine Peso(PhP)");

我做错了什么?

【问题讨论】:

    标签: c# selenium selenium-webdriver


    【解决方案1】:

    我对 selenium 的 c# 实现不太熟悉,只是 java。也许只是缺少一些空格或类似的东西。请尝试以下方法:

    WebElement webElement = driver.findElements(By.xpath("//select[@id='CountrySelector']//option[text()='Philippines-Philippine Peso(PhP)']"));
    Assert.assertTrue(webElement.isDisplayed());
    

    (对不起,这是java,也许你必须修改代码,但我想你明白了......)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-05
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多