Unable to click option in dropdown list selenium

python selenium select
how to get the selected value of dropdown in selenium webdriver
how to handle dropdown without select in selenium
selenium select dropdown python
how to verify dropdown values in selenium c#
select class not working in selenium webdriver
how to test react js dropdown with selenium and java
how to get selected value from dropdown list in python selenium

I tried using the Select module, but when I do the Element is either not interactable or it is "not visible". Here are the relevant codes.

HTML

    < head >
    < script >

        function onChangeCardType() {
            var value = $('#card_type').val();
            $('#img_' + value).siblings().hide();
            $('#img_' + value).show();
        }

    </script>

</head>

<body>
    <table>
        <thead>

            <tr>
                <th align="left">Card type</th>
                <td colspan="2" style="font-size:12px;">
                    <select name="requestDTO.vpc_card" id="card_type" onchange="onChangeCardType()"
                            class="select required"
                            style="width: 342px; font-size:12px;">
                        <option value="Amex" >American Express</option>
                        <option value="Mastercard" >MasterCard</option>
                        <option value="Visa" >Visa</option>
                        <option value="JCB" >JCB</option>
                    </select>
                    <a class="ui-selectmenu ui-widget ui-state-default select required ui-selectmenu-dropdown ui-corner-all" id="card_type_button_435" role="button" href="#" aria-haspopup="true" aria-owns="card_type_menu_435" aria-expanded="false" tabindex="0" style="width: 336px;"><span class="ui-selectmenu-status">Visa</span><span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span></a>
                        <span class="ui-selectmenu-status">Visa</span>

                        <span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span>

                </td>
            </tr>

         </thead>
    </table>
</body>

Code

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

from time import sleep
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.support.ui import Select

#testing on a website that's not public yet, so I won't show the set-up here,but if it's required I can too

cardtype = Select(driver.find_element_by_id("card_type"))
cardtype.select_by_value("Mastercard")
sleep(1)
driver.implicitly_wait(2)


Using Firefox: ElementNotInteractableException:
Element <option> could not be scrolled into view


Using Chrome:
ElementNotVisibleException: element not visible: 
Element is not currently visible and may not be manipulated

# sleep nor implicitly_wait doesn't help too...

I also tried just clicking on the box (not using the select tag, I could click on it using the class="ui-selectmenu", but .send_keys(KEYS.ARROW_DOWN) doesn't work (gives an AttributeError).

Is there a way I can identify the text in an option and click on it without using the Select module? Or is there a way I can get the Select module to work in this case? Any illuminating response is welcomed!!


You can use select_by_index. I personally recommend instead of value

cardtype = Select(driver.find_element_by_id("card_type"))
cardtype.select_by_index(1)  // 0 - AMEX , 1 - MasterCard and so on

Unable to click on dropdown element using for loop, //ul[@class='dropdown-menu inner selectpicker']/li/a. Note that this means you may also have to adjust your option string matching logic. Rather  Select Option from Drop-Down Box. Before we can control drop-down boxes, we must do following two things: Import the package org.openqa.selenium.support.ui.Select. Instantiate the drop-down box as a "Select" object in WebDriver.


thanks so much for the responses! Unfortunately, the problem was really not with wait in this case:/

What did work for me however, was Action Chains. Actions Chains works because you don't have to target an element. So in my post I mentioned I could click the dropdown list, and that down arrows didn't work because it gave an AttributeError. However, that was because I tried targeting the element!

So here's the answer that worked for me:

cardtype = driver.find_elements_by_class_name("ui-selectmenu-status")
cardtype.click()

actions = ActionChains(driver)
actions.send_keys(Keys.ARROW_DOWN)
actions.send_keys(Keys.ENTER)
actions.perform()

An options in a drop-down can't be click although they are clickable , I try to perform these two test steps with Selenium Chromedriver (2.15.322488) (Selenium 2.48.2) 1/Click on a dropdown 2/Click on an option from this dropdown I methodOfTestStep.click(); List<WebElement> li = driver. You received this message because you are subscribed to the Google Groups "Selenium Users" group. Unable to Click on Dropdown option


Try this.

your_choice=driver.find_element_by_xpath("//select[@id='card_type']/option[@value='Mastercard']")
your_choice.click()

Usage of Selenium Select Class for Handling Dropdown Elements , Selenium Select Options: We would concentrate on handling the various and “​http://www.abodeqa.com/” respectively on the click event. Select a city from the ‘From’ drop down list. To automate the selection of a city from the list in the ‘from’ drop down field we will make use of the xpath locator strategy. Right click on the city you would like to select, scroll down the list to option to ‘inspect’ this element.


You can try this code :

WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.ID, "card_type")))  
cardtype = Select(driver.find_element_by_id('card_type'))
cardtype.select_by_value("Mastercard")  
#OR  

cardtype.select_by_visible_text('MasterCard')  

Hope this will be helpful.

Unable to Click and select the option from dropdown textbox, On click of textbox it shows dropdown list. But When i run the script it doesn't work​. I am not able to click on textbox and select a option from dropdown. Repository/Address zone/li_L1' (Root cause: org.openqa.selenium. It's only when I want an element that is farther down the list that it fails to properly click. Usually when you use .Click() it auto-scrolls to the element desired. Other notes: The weird part is it is doing something. Because when it performs the faulty .Click() in step (2), the drop down list closes. It just doesn't select anything.


You need to wait for a while(2 Seconds), Before Select actions. You can use Explicit Wait or sleep. That will solve Firefox as well as Chrome problem.

Explicit Wait :

from selenium.webdriver.support import expected_conditions as EC
element = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "card_type")))

Sleep:

import time
time.sleep( 5 )

I am trying to select one of the dropdown list value using select class , <ul id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" I could able to click on the dropdown list using the below code: unable to select the value in the dropdown list,getting the following error message: How to get the attribute value of a web element in Selenium (using Java or Python)?. To select a drop-down menu option value with Selenium (Python), firstly you need to import the Select class and then you need to create the instance of Select class. After completing these two steps you will need to create the instance of Select class, you can perform select methods on that instance to select an option from the dropdown list.


Select each option in a drop down using Selenium WebDriver C# , I'm not able to select options in a drop-down list. I think I need to have. Select or using OpenQA.Selenium.IE; using OpenQA.Selenium.


How To Select from a Dropdown List, Selecting from a dropdown list seems like one of those simple things. |option| option.click if option.text == 'Option 1' } selected_option = options.map { |option| 


Trying to choose an option from a dropdown list but can't use Select , I have no add-ons installed so that shouldn't be the problem. Like go to http://​www.newegg.com/ and click search menu, I can't select any options.