Java 在selenium中找不到下拉列表元素

Java 在selenium中找不到下拉列表元素,java,select,iframe,selenium,Java,Select,Iframe,Selenium,我已经使用selenium编写了一个基本测试。测试失败,因为selenium无法从下拉列表中选择项目 我的select语句未被执行。我还将这个select语句包含在iframe中,因为它属于iframe 你能告诉我我的select声明有什么问题吗 这是我的西南网站代码: 正如@SiKing所说的,您的问题在于您的文本不可访问。您需要选择VisibleText 我还想指出,如果您刚刚开始,检查框架可能会更容易。如果您使用的是maven,您可以: <dependency> <g

我已经使用selenium编写了一个基本测试。测试失败,因为selenium无法从下拉列表中选择项目

我的select语句未被执行。我还将这个select语句包含在iframe中,因为它属于iframe

你能告诉我我的select声明有什么问题吗

这是我的西南网站代码:


正如@SiKing所说的,您的问题在于您的文本不可访问。您需要选择VisibleText

我还想指出,如果您刚刚开始,检查框架可能会更容易。如果您使用的是maven,您可以:

<dependency>
  <groupId>io.ddavison</groupId>
  <artifactId>getting-started-with-selenium-framework</artifactId>
  <version>1.2</version>
</dependency>
取消选择VisibleText?你确定你的意思是取消选择,而不仅仅是选择?
uiHomeAp.selectByVisibleText("Atlanta, GA - ATL");
<dependency>
  <groupId>io.ddavison</groupId>
  <artifactId>getting-started-with-selenium-framework</artifactId>
  <version>1.2</version>
</dependency>
@Config(browser = Browser.CHROME, url="http://www.southwest.com/")
public class FirstWDWithoutRecording extends AutomationTest {
    public void southWestSignUp() {
        click(By.linkText("Sign up"))
        .switchToFrame(0)
        .setText("input#FIRST_NAME", "abc")
        .setText("input#LAST_NAME", "Kish123")
        .setText("input#EMAIL", "abc@Kish123.com")
        .selectOptionByText("select#HOME_AIRPORT", "Atlanta, GA - ATL")
        .check("#IAN") // check the terms and conditions
        .click("#submit") // form submitted
        .switchToDefaultContent()
        ;
    }
}