Selenium - Selecting an item from dropdown list if the values are inside <table> tags and NOT under <option> in html

sjkp

The below is a snippet from our html code which appears as a drop down list in the application. I am unable to select a particular value from the drop down list using Select class in Selenium - possibly because it doesn't have "Option" tags?. Is there any way to select the item?

-UPDATE: This has a parent tag which talks about visibility. Basically to tell that elements are visible only if the user clicks the drop down arrow. "< input type="hidden" *****"

For e.g. I need to select 'I am option2' from the list during the test execution.

<div id="xyz" class="DropdownInnerContainer" style="z-index:99999;">
<table id="abc" class="DropdownItemContainer" list="1000020">
    <tr class="">
        <td value="" index="0" title="">&nbsp;
        </td>
        <td class="BorderCell"></td>
    </tr>
    <tr class="">
        <td value="I am option1" index="1" plid="1002827">I am option1</td>
        <td class="BorderCell"></td>
    </tr>
    <tr class="">
        <td value="I am option2" index="2" plid="1002828">I am option2</td>
        <td class="BorderCell"></td>
    </tr>
    <tr class="">
        <td value="I am option3" index="3" plid="1002829">I am option3</td>
        <td class="BorderCell"></td>
    </tr>
    <tr class="">
        <td value="I am option4" index="4" plid="1002830">I am option4</td>
        <td class="BorderCell"></td>
    </tr>
</table>

sjkp

It appears that since the drop down options were inside a < table >, the Select class was unable to identify the list options. So here's what I did:

First click() the dropdown, which opens up the menu:

driver.findElement(By.xpath(".//*[@id='abc01_tbl']/div/div")).click();

Then pass the value using the contains() method and then click() on it.

driver.findElement(By.xpath(".//*[@id='xyz01_tbl']/tbody/tr/td[1][contains(text(),'I am option2')]")).click();

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Display dropdown list inside html table

分類Dev

Selenium Select - Selecting dropdown option by part of the text

分類Dev

Selenium selecting value from dropdown

分類Dev

Selecting item in nested html Frame with Selenium WebDriver

分類Dev

JavaScript/HTML - Keeping numeric values from select dropdown list selected

分類Dev

Issue Selecting DB value from DropDown List when Page is generated

分類Dev

How to fetch values from different html input tags inside multiple divs?

分類Dev

HTML Agility Pack - Issue selecting an HTML select tag with the option tags within

分類Dev

Selecting an item with multiple conditions from a list using Espresso

分類Dev

Php retrieve a set of values from an unique SQL row and display it in an HTML option list

分類Dev

Selecting values inside array in jsonb

分類Dev

Selenium Python I can iterate over the html table how do I print the values from column 3

分類Dev

Scrapping data from html table, selecting elements between titles

分類Dev

After selecting the value from dropdown list then it shows no any value next time

分類Dev

Filter a html table using dropdown colum list by jQuery

分類Dev

How could I select an item from list using selenium?

分類Dev

Remove DropDownListFor selection when selecting a specific option in another dropdown

分類Dev

How to fill dropdown list options with values from database in rails?

分類Dev

Retain dynamic values from Dropdown list after page refresh in Laravel

分類Dev

Create a list of values from a table of values and exclude certain values

分類Dev

find item inside list of list

分類Dev

Selecting random values from dictionary

分類Dev

Selecting columns from a table in memory

分類Dev

Selecting unique rows from a table having duplicate values in only one column

分類Dev

Dropdown select option pagination in ng-table

分類Dev

Looping into a Table and getting values from different Inputs inside the Columns

分類Dev

Python selenium how to scrape list of values from website

分類Dev

Delete Table Row from nested <ul> list item

分類Dev

Kafka-stream : How to re-key a stream by selecting key from a list of values

分類Dev

Ideas Needed: AngularJS: Select Dropdown with several Option Tags

Related 関連記事

  1. 1

    Display dropdown list inside html table

  2. 2

    Selenium Select - Selecting dropdown option by part of the text

  3. 3

    Selenium selecting value from dropdown

  4. 4

    Selecting item in nested html Frame with Selenium WebDriver

  5. 5

    JavaScript/HTML - Keeping numeric values from select dropdown list selected

  6. 6

    Issue Selecting DB value from DropDown List when Page is generated

  7. 7

    How to fetch values from different html input tags inside multiple divs?

  8. 8

    HTML Agility Pack - Issue selecting an HTML select tag with the option tags within

  9. 9

    Selecting an item with multiple conditions from a list using Espresso

  10. 10

    Php retrieve a set of values from an unique SQL row and display it in an HTML option list

  11. 11

    Selecting values inside array in jsonb

  12. 12

    Selenium Python I can iterate over the html table how do I print the values from column 3

  13. 13

    Scrapping data from html table, selecting elements between titles

  14. 14

    After selecting the value from dropdown list then it shows no any value next time

  15. 15

    Filter a html table using dropdown colum list by jQuery

  16. 16

    How could I select an item from list using selenium?

  17. 17

    Remove DropDownListFor selection when selecting a specific option in another dropdown

  18. 18

    How to fill dropdown list options with values from database in rails?

  19. 19

    Retain dynamic values from Dropdown list after page refresh in Laravel

  20. 20

    Create a list of values from a table of values and exclude certain values

  21. 21

    find item inside list of list

  22. 22

    Selecting random values from dictionary

  23. 23

    Selecting columns from a table in memory

  24. 24

    Selecting unique rows from a table having duplicate values in only one column

  25. 25

    Dropdown select option pagination in ng-table

  26. 26

    Looping into a Table and getting values from different Inputs inside the Columns

  27. 27

    Python selenium how to scrape list of values from website

  28. 28

    Delete Table Row from nested <ul> list item

  29. 29

    Kafka-stream : How to re-key a stream by selecting key from a list of values

  30. 30

    Ideas Needed: AngularJS: Select Dropdown with several Option Tags

ホットタグ

アーカイブ