FAQ
Hi,

The code below for dropdown box to select value is perfectly working
fine with firefox and IE browser but same function is not working with
Chrome browser. Any help is much appreciated. The code of the function
is below.

=======================================================================
WebElement selectElement = driver.findElement(byType);
Select selection = new Select(selectElement);
List<WebElement> allMenus = selection.getOptions();
for (WebElement web : allMenus) {
if (web.getText().equalsIgnoreCase(value)) {
web.click();
break;

}
}

=======================================================================

I tried below code also but still not working. Is it know issue with
selenium for chrome browser?

public void selectFromDropDown(By ByLocator, String valueString)
throws Exception
{
Select select;


waitForElementPresent(ByLocator, timeout); // Wait until
present
select = new Select(driver.findElement(ByLocator));
select.selectByValue(valueString);
} // selectFromDropDown(String locatorString, String
valueString)


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Search Discussions

  • Mike Riley at May 24, 2012 at 4:33 pm
    I believe that was working for me with Chrome, although right now I am
    testing on with IE. However, one of my test suites has about 15 tests that
    all interact with a select list and it worked fine with Chrome.

    Can you share the HTML and your code calling the selectFromDropDoown()
    method?

    BTW - a new version of the ChromeDriver.exe is available for download. I
    doubt that is what you need to fix the issue though. I have been using the
    19.1068.0 version forever.

    Mike
    On Tuesday, May 22, 2012 3:49:13 PM UTC-7, bhasky wrote:

    Hi,

    The code below for dropdown box to select value is perfectly working
    fine with firefox and IE browser but same function is not working with
    Chrome browser. Any help is much appreciated. The code of the function
    is below.

    =======================================================================
    WebElement selectElement = driver.findElement(byType);
    Select selection = new Select(selectElement);
    List<WebElement> allMenus = selection.getOptions();
    for (WebElement web : allMenus) {
    if (web.getText().equalsIgnoreCase(value)) {
    web.click();
    break;

    }
    }

    =======================================================================

    I tried below code also but still not working. Is it know issue with
    selenium for chrome browser?

    public void selectFromDropDown(By ByLocator, String valueString)
    throws Exception
    {
    Select select;


    waitForElementPresent(ByLocator, timeout); // Wait until
    present
    select = new Select(driver.findElement(ByLocator));
    select.selectByValue(valueString);
    } // selectFromDropDown(String locatorString, String
    valueString)

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/cjH_vJJqwakJ.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
  • Techie Software at May 29, 2012 at 10:33 pm
    Hi Mike,
    Thanks for replay. I have the latest version of chrome browser what you
    have. It works fine in IE (8.0) and Firefox(latest) but same code is not
    working in chrome. I have browsed selenium group and come to know in one of
    the forum that selenium has issue with chrome for dropdown boxes. Can you
    please help whether there is fix on this or correct if i am doing wrong. i
    have pasted html and my code below.


    <div class="dob">
    <label class="dob-label register-label">
    <select class="dob-dropdown selectBox" data-error="Please enter a date of
    birth." required="required" name="dobMonth" style="display: none;">
    <a class="selectBox dob-dropdown selectBox-dropdown selectBox-open
    selectBox-menuShowing" style="display: inline-block; -moz-user-select: none;
    " title="" tabindex="0">
    <span class="selectBox-label">MM</span>
    <span class="selectBox-arrow"></span>
    </a>
    <select class="dob-dropdown selectBox" data-error="Please enter a date of
    birth." required="required" name="dobDay" style="display: none;">
    <a class="selectBox dob-dropdown selectBox-dropdown" style="display:
    inline-block; -moz-user-select: none;" title="" tabindex="0">
    <span class="selectBox-label">DD</span>
    <span class="selectBox-arrow"></span>
    </a>
    <a class="selectBox dob-dropdown selectBox-dropdown" style="display:
    inline-block; -moz-user-select: none;" title="" tabindex="0">
    <span class="selectBox-label">YYYY</span>
    <span class="selectBox-arrow"></span>
    </a>
    </div>



    public static void main(String[] args) throws Exception {

    selectFromDropDown(By.xpath("/html/body/div/div/div/div/form/div[2]/div[2]/div[4]/a/span"),"3");

    }


    // selectFromDropDown(String locatorString, String valueString)

    *public* *static* *void* selectFromDropDown(By ByLocator, String
    valueString)

    *throws* Exception

    {

    Select select;

    //WebDriverWait(ByLocator, 15); // Wait until present

    select =
    *new* Select(*driver*.findElement(ByLocator));

    select.selectByValue(valueString);

    }

    On Thu, May 24, 2012 at 9:33 AM, Mike Riley wrote:

    I believe that was working for me with Chrome, although right now I am
    testing on with IE. However, one of my test suites has about 15 tests that
    all interact with a select list and it worked fine with Chrome.

    Can you share the HTML and your code calling the selectFromDropDoown()
    method?

    BTW - a new version of the ChromeDriver.exe is available for download. I
    doubt that is what you need to fix the issue though. I have been using the
    19.1068.0 version forever.

    Mike

    On Tuesday, May 22, 2012 3:49:13 PM UTC-7, bhasky wrote:

    Hi,

    The code below for dropdown box to select value is perfectly working
    fine with firefox and IE browser but same function is not working with
    Chrome browser. Any help is much appreciated. The code of the function
    is below.

    ==============================**==============================**===========

    WebElement selectElement = driver.findElement(byType);
    Select selection = new Select(selectElement);
    List<WebElement> allMenus = selection.getOptions();
    for (WebElement web : allMenus) {
    if (web.getText().**equalsIgnoreCase(value)) {
    web.click();
    break;

    }
    }

    ==============================**==============================**===========


    I tried below code also but still not working. Is it know issue with
    selenium for chrome browser?

    public void selectFromDropDown(By ByLocator, String valueString)
    throws Exception
    {
    Select select;


    waitForElementPresent(**ByLocator, timeout); // Wait until
    present
    select = new Select(driver.findElement(**ByLocator));
    select.selectByValue(**valueString);
    } // selectFromDropDown(String locatorString, String
    valueString)


    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/cjH_vJJqwakJ.

    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/selenium-users?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.
  • Mark Collin at May 29, 2012 at 11:12 pm
    From what you have shown below your <select> element has no closing tag and
    no <option> elements.



    It's not valid HTML so it's not going to work.



    From: selenium-users@googlegroups.com
    On Behalf Of Techie Software
    Sent: 29 May 2012 23:33
    To: selenium-users@googlegroups.com
    Subject: Re: [selenium-users] Re: dropdown box issue for chrome browser





    Hi Mike,

    Thanks for replay. I have the latest version of chrome browser what you
    have. It works fine in IE (8.0) and Firefox(latest) but same code is not
    working in chrome. I have browsed selenium group and come to know in one of
    the forum that selenium has issue with chrome for dropdown boxes. Can you
    please help whether there is fix on this or correct if i am doing wrong. i
    have pasted html and my code below.





    <div class="dob">

    <label class="dob-label register-label">

    <select class="dob-dropdown selectBox" data-error="Please enter a date of
    birth." required="required" name="dobMonth" style="display: none;">

    <a class="selectBox dob-dropdown selectBox-dropdown selectBox-open
    selectBox-menuShowing" style="display: inline-block; -moz-user-select:
    none;" title="" tabindex="0">

    <span class="selectBox-label">MM</span>

    <span class="selectBox-arrow"></span>

    </a>

    <select class="dob-dropdown selectBox" data-error="Please enter a date of
    birth." required="required" name="dobDay" style="display: none;">

    <a class="selectBox dob-dropdown selectBox-dropdown" style="display:
    inline-block; -moz-user-select: none;" title="" tabindex="0">

    <span class="selectBox-label">DD</span>

    <span class="selectBox-arrow"></span>

    </a>

    <a class="selectBox dob-dropdown selectBox-dropdown" style="display:
    inline-block; -moz-user-select: none;" title="" tabindex="0">

    <span class="selectBox-label">YYYY</span>

    <span class="selectBox-arrow"></span>

    </a>

    </div>







    public static void main(String[] args) throws Exception {



    selectFromDropDown(By.xpath("/html/body/div/div/div/div/form/div[2]/div[2]/d
    iv[4]/a/span"),"3");



    }



    // selectFromDropDown(String locatorString, String valueString)

    public static void selectFromDropDown(By ByLocator, String valueString)

    throws Exception

    {

    Select select;

    //WebDriverWait(ByLocator, 15); // Wait until present

    select =

    new Select(driver.findElement(ByLocator));

    select.selectByValue(valueString);

    }



    On Thu, May 24, 2012 at 9:33 AM, Mike Riley wrote:

    I believe that was working for me with Chrome, although right now I am
    testing on with IE. However, one of my test suites has about 15 tests that
    all interact with a select list and it worked fine with Chrome.

    Can you share the HTML and your code calling the selectFromDropDoown()
    method?

    BTW - a new version of the ChromeDriver.exe is available for download. I
    doubt that is what you need to fix the issue though. I have been using the
    19.1068.0 version forever.

    Mike



    On Tuesday, May 22, 2012 3:49:13 PM UTC-7, bhasky wrote:

    Hi,

    The code below for dropdown box to select value is perfectly working
    fine with firefox and IE browser but same function is not working with
    Chrome browser. Any help is much appreciated. The code of the function
    is below.

    =======================================================================
    WebElement selectElement = driver.findElement(byType);
    Select selection = new Select(selectElement);
    List<WebElement> allMenus = selection.getOptions();
    for (WebElement web : allMenus) {
    if (web.getText().equalsIgnoreCase(value)) {
    web.click();
    break;

    }
    }

    =======================================================================

    I tried below code also but still not working. Is it know issue with
    selenium for chrome browser?

    public void selectFromDropDown(By ByLocator, String valueString)
    throws Exception
    {
    Select select;


    waitForElementPresent(ByLocator, timeout); // Wait until
    present
    select = new Select(driver.findElement(ByLocator));
    select.selectByValue(valueString);
    } // selectFromDropDown(String locatorString, String
    valueString)



    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.

    To view this discussion on the web visit
    https://groups.google.com/d/msg/selenium-users/-/cjH_vJJqwakJ.


    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com
    .
    For more options, visit this group at
    http://groups.google.com/group/selenium-users?hl=en.



    --
    You received this message because you are subscribed to the Google Groups
    "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to
    selenium-users+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/selenium-users?hl=en.

    --
    You received this message because you are subscribed to the Google Groups "Selenium Users" group.
    To post to this group, send email to selenium-users@googlegroups.com.
    To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedMay 23, '12 at 6:31p
activeMay 29, '12 at 11:12p
posts4
users3
websiteseleniumhq.org

People

Translate

site design / logo © 2022 Grokbase