FAQ
Hi All,

I have a scenario to verify...

Scenario: There is a dropdwon, when i will click on that drop down the
dropdown box will show up with the all the dropdown items..And when i will
click outside that drop down box will disappear...Is there anyway to
automate this in Selenium WebDriver?

Thanks,

Sudhansu

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6c53f53a-893e-48f2-96ce-6d8e39a5b269%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Doug Dragon at Jul 9, 2014 at 5:23 pm
    Not sure if this is what you're looking for but I wrote this to interact
    with the options in a dropdown box:
    (In Python):
    def get_dropdown_options(driver, dropdown_locator):
         """ Returns a list of all options for a given dropdown selector
         required params:
         @dropdown_locator == CSS location of dropdown """
         dropdown_options = driver.find_elements_by_css_selector(
             dropdown_locator + " option")
         options = []
         for option in dropdown_options:
             options.append(option.text)
         return options

    Then you'll have a variable (dropdown_options) that contains a list of all
    the options in the dropdown.

    Hope that helps,

    -Doug

    On Wednesday, July 9, 2014 10:06:28 AM UTC-4, Sudhansu Sekhar panda wrote:

    Hi All,

    I have a scenario to verify...

    Scenario: There is a dropdwon, when i will click on that drop down the
    dropdown box will show up with the all the dropdown items..And when i will
    click outside that drop down box will disappear...Is there anyway to
    automate this in Selenium WebDriver?

    Thanks,

    Sudhansu
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/67dfa5dd-3cd2-4b43-af37-5021ec46e7fa%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Harsh Ma at Jul 10, 2014 at 3:47 am
    Hey if it is possible to do Manually, for sure it can be automated!!
    1. Is it possible to do it Manually?
    2. What have u tried?
    3. If tried then what is the code & What point is it failing?

    Thanks
    Harsh Ma
    On Wednesday, July 9, 2014 7:36:28 PM UTC+5:30, Sudhansu Sekhar panda wrote:

    Hi All,

    I have a scenario to verify...

    Scenario: There is a dropdwon, when i will click on that drop down the
    dropdown box will show up with the all the dropdown items..And when i will
    click outside that drop down box will disappear...Is there anyway to
    automate this in Selenium WebDriver?

    Thanks,

    Sudhansu
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/013bbf73-e417-4912-997b-002ce3a08faa%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sudhansu Sekhar panda at Jul 10, 2014 at 5:29 am
    Hi Harsh,

    Yes while doing manually the dropdown box is getting collapsed but the
    elements are still there.... I tried using isDisplayed() method but it did
    not work for me...
    On Thursday, 10 July 2014 09:17:43 UTC+5:30, Harsh Ma wrote:

    Hey if it is possible to do Manually, for sure it can be automated!!
    1. Is it possible to do it Manually?
    2. What have u tried?
    3. If tried then what is the code & What point is it failing?

    Thanks
    Harsh Ma

    On Wednesday, July 9, 2014 7:36:28 PM UTC+5:30, Sudhansu Sekhar panda
    wrote:
    Hi All,

    I have a scenario to verify...

    Scenario: There is a dropdwon, when i will click on that drop down the
    dropdown box will show up with the all the dropdown items..And when i will
    click outside that drop down box will disappear...Is there anyway to
    automate this in Selenium WebDriver?

    Thanks,

    Sudhansu
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c44ad747-1e3d-4b26-b844-eee038138f19%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Phanindra Chowdary Chunduri at Jul 10, 2014 at 6:33 am
    This scenario automation depends on UI development.

    this scenario is possible when you click on a element(dropdown) all the
    options will be displayed in a new div. Verify the options if you want.
    Click some where else that div will be hidden. We can verify for no
    existence of this div and automate scenario.

    If the control which u are clicking is a <select> then there is no way to
    say the dropdown is expanded or minimized.

    Check the dom of your app.

    Thanks,
    Phanindra


    On Thursday, July 10, 2014 10:59:15 AM UTC+5:30, Sudhansu Sekhar panda
    wrote:
    Hi Harsh,

    Yes while doing manually the dropdown box is getting collapsed but the
    elements are still there.... I tried using isDisplayed() method but it did
    not work for me...
    On Thursday, 10 July 2014 09:17:43 UTC+5:30, Harsh Ma wrote:

    Hey if it is possible to do Manually, for sure it can be automated!!
    1. Is it possible to do it Manually?
    2. What have u tried?
    3. If tried then what is the code & What point is it failing?

    Thanks
    Harsh Ma

    On Wednesday, July 9, 2014 7:36:28 PM UTC+5:30, Sudhansu Sekhar panda
    wrote:
    Hi All,

    I have a scenario to verify...

    Scenario: There is a dropdwon, when i will click on that drop down the
    dropdown box will show up with the all the dropdown items..And when i will
    click outside that drop down box will disappear...Is there anyway to
    automate this in Selenium WebDriver?

    Thanks,

    Sudhansu
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f9c1e5b2-8d77-4cf1-bc48-dbbe9bdb6a1d%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Icar Napiza at Jul 11, 2014 at 9:28 am
    This is how i resolved my issue of not consistently select a value on a
    dropdown, having items not visible because its at the bottom of the
    dropdown. THis can be shorten by using iList or Array..

      Public Sub doDropDownSelect(by As By, xpath As String, Optional
    valueToSelect As String = "")
                 'USAGE: dropDownSelect(dropdownid,"//*[@id='dropdown
    id']/a/span","item in string")
                 Try
                     If Sync(driver, by) Then
                         Sleep(1000)
                         ClickElement(by)
                         Dim myElement As IWebElement = driver.FindElement(by)
                         Dim myXpath = String.Format("//*[@id='{0}']/a/span",
    by.ToString)

                         Dim myElements As
    System.Collections.ObjectModel.ReadOnlyCollection(Of IWebElement) =
    myElement.FindElements(by.TagName("li"))

                         Dim r As New Random
                         Dim i As Integer = r.Next(0, myElements.Count - 1)
                         Dim j As Integer = 0
                         Dim k As Integer = 0

                         Dim mySelectedValue As String =
    driver.FindElement(by.XPath(String.Format(xpath))).Text
                         'Get the index current selected value if any
                         If mySelectedValue <> "choose..." Then
                             For Each e As IWebElement In myElements
                                 If e.Text = mySelectedValue Then
                                     Exit For
                                 Else
                                     j = j + 1
                                 End If
                             Next
                         End If
                         'mySelectedValue = myElements.item(j)

                         If valueToSelect = "" Then
                             valueToSelect = myElements.Item(i).Text
                         Else
                             For Each e As IWebElement In myElements
                                 k = k + 1
                                 If e.Text.Trim = valueToSelect.Trim Then
                                     'valuetoselect = myelements.item(k)
                                     i = k
                                     Exit For
                                 End If
                             Next
                         End If

                         Dim t As Boolean = myElements.Item(i).Displayed
                         Dim y As String = myElements.Item(i).Text

                         While myElements.Item(i).Displayed <> True
                             If j > i Then
                                 Dim Action = New
    OpenQA.Selenium.Interactions.Actions(driver).SendKeys(Keys.ArrowUp)
                                 Action.Perform()
                             Else
                                 Dim Action = New
    OpenQA.Selenium.Interactions.Actions(driver).SendKeys(Keys.ArrowDown)
                                 Action.Perform()
                             End If
                             If valueToSelect = myElements.Item(i).Text Then

                                 Exit While
                             End If
                         End While
                         myElements.Item(i).Click()
                     End If
                 Catch ex As Exception
                     Throw ex
                 End Try
             End Sub
    On Wednesday, July 9, 2014 7:06:28 AM UTC-7, Sudhansu Sekhar panda wrote:

    Hi All,

    I have a scenario to verify...

    Scenario: There is a dropdwon, when i will click on that drop down the
    dropdown box will show up with the all the dropdown items..And when i will
    click outside that drop down box will disappear...Is there anyway to
    automate this in Selenium WebDriver?

    Thanks,

    Sudhansu
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2f943092-83d2-4d19-a506-718189352bfb%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Anuj Sharma at Jul 11, 2014 at 9:29 am
    You can click using the click() method using the "Actions" class to another
    web element on the page.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
    To post to this group, send email to selenium-users@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/33a89594-c21c-46a6-a71b-24bca7e42c1e%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedJul 9, '14 at 2:06p
activeJul 11, '14 at 9:29a
posts7
users6
websiteseleniumhq.org

People

Translate

site design / logo © 2022 Grokbase