Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97808

Not able to select drop-down option using select : UnexpectedTagNameException selenium : python

$
0
0

I apologize if I am doing very basic mistake, i am still new learning webdriver and python.

I am trying to select an option from dropdown using Select Class of python, but i am getting Unexpected TagName exception. There is no ID present on the Tag, so i cannot detect it using any other method except class or attribute.

HTML Code :

<div class="select-pixels-container ng-scope">
    <div class="action group">
    <table class="org-agency-advertiser">
    <tbody style="background-color: transparent;">
        <tr style="background-color: transparent;">
        <tr>
            <td style="background-color: transparent;">
                <select class="mm-select ng-valid localytics-chosen ng-dirty" ng-disabled="disabled('organizations')" ng-options="org.id as org.name for org in logic.organizations | orderBy:'name'" ng-model="logic.organization" chosen="" style="display: none;" data-placeholder="Select an Option">
                <div class="chosen-container chosen-container-single" style="width: 175px; background-color: transparent;" title="">
                    <a class="chosen-single" tabindex="-1" style="background-color: transparent;">
                        <span style="background-color: transparent;">Select</span>
                        <div>
                    </a>
                    <div class="chosen-drop">
                        <div class="chosen-search">
                            <input type="text" autocomplete="off">
                        </div>
                        <ul class="chosen-results">
                            <li class="active-result" style="" data-option-array-index="0">Select</li>
                            <li class="active-result" style="" data-option-array-index="1">1-800 Hnunagk 100278</li>
                            <li class="active-result result-selected" style="" data-option-array-index="2">10tc Tatgaa 100179</li>

The code which I have wrote for this section is :

self.driver.find_element_by_css_selector("tbody>tr>td>div>a.chosen-single").click()
select=Select(self.driver.find_element_by_css_selector("tbody>tr>td>div>a[tabindex='-1']"))
select.select_by_index(0)

The exception I am getting is

selenium.common.exceptions.UnexpectedTagNameException: Message: Select only works on <select> elements, not on <a>`

Any help will be appreciated.


Viewing all articles
Browse latest Browse all 97808

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>