Selecting item from dropdown using Selenium

2019-09-02 00:05发布

I need to use Selenium to select Cars/data-option-array-index="5" from the dropdown below:

<!-- Activity -->
<div class="field clearfix">
  <label for="infosActivity" class="aligned">Main activity</label>
  <div class="contentinput">
    <select id="infosActivity" name="shop_activity" class="chosen">
      <option value="0" style="font-weight: bold" selected="selected">Please choose your main activity</option>
      <option value="2" >Animals and Pets</option>
      <option value="3" >Art and Culture</option>
      <option value="4" >Babies</option>
      <option value="5" >Beauty and Personal Care</option>
      <option value="6" >Cars</option>
      <option value="0">Other activity...</option>
    </select>
  </div>
  <p class="userInfos aligned">Help us learn more about your store 
  so we can offer you optimal guidance and the best features for your business!</p>
</div>
<input value="full" name="db_mode" type="hidden" />

I've tried the following:

1. driver.find_element_by_id("infosActivity").send_keys('Cars') => error:

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

2.Select(driver.find_element_by_id("infosActivity")).select_by_visible_text('Cars')=> error:

Selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated

Whatever I try I get element not visible.

0条回答
登录 后发表回答