Selecting item from dropdown using Selenium

你离开我真会死。 提交于 2019-12-25 02:28:29

问题


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.

来源:https://stackoverflow.com/questions/52294584/selecting-item-from-dropdown-using-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!