元素不可见:元素当前不可见且不可操作 - Selenium webdriver

Osa*_*qui 7 selenium

以下是html

<div id="form1:customertype" class="ui-selectonemenu ui-widget ui-state-default ui-corner-all ui-state-hover" style="width: 165px;">
   <div class="ui-helper-hidden-accessible">
      <select id="form1:customertype_input" name="form1:customertype_input" tabindex="-1">
         <option value="S">Staff</option>
         <option value="C">Customer</option>
         <option value="N">New To Bank</option></select></div>
  <div class="ui-helper-hidden-accessible"><input id="form1:customertype_focus" name="form1:customertype_focus" type="text" readonly="readonly"></div>
  <label id="form1:customertype_label" class="ui-selectonemenu-label ui-inputfield ui-corner-all" style="width: 149px;">Staff</label>
  <div class="ui-selectonemenu-trigger ui-state-default ui-corner-right ui-state-hover"><span class="ui-icon ui-icon-triangle-1-s ui-c"></span></div></div>
Run Code Online (Sandbox Code Playgroud)

class="ui-helper-hidden-accessible" 的样式表是

ui-helper-hidden-accessible {
      border: 0;
      clip: rect(0 0 0 0);
      height: 0px;
      margin: -1px;
      overflow: hidden;
      padding: 0;
      position: absolute;
      width: 0px;
   }
Run Code Online (Sandbox Code Playgroud)

以下是我的代码

    WebElement customerType = driver.findElement(By.id("form1:customertype_input"));
    Select select = new Select(customerType);
    select.selectByVisibleText("New To Bank");
Run Code Online (Sandbox Code Playgroud)

当我尝试从下拉列表中选择“New to Bank”时,出现异常元素不可见:元素当前不可见且可能无法操作 - Selenium webdriver

我尝试过 WebDriverWait 技术但没有用,有什么想法吗?

Var*_*pai 0

在创建Select对象之前尝试单击customerType