How to select an option of a javascript dropdown which is having no element for its options …

I am able to click on dropdown element but is unable to select any option in dropdown .

“Select” class is also not working as it is a td .

What i should do ??

Train Asked on August 22, 2014 in Selenium WebDriver.
Add Comment
  • 8 Answer(s)

    Hi sajal,

    Visit http://www.toolsqa.com/selenium-webdriver/dropdown-multiple-select-operations/ site. You can get clear understanding about the problem you are facing.

    Regards,
    Vaidy

    Doctor Answered on August 22, 2014.
    Add Comment

    Hi Sajal,

    Try using FIREPATH tool of Firefox and get the xpath of the Select element and click on it. Once you click it, other values will get populated and again with the help of xpath you would be able to select the value of the Select element. For understanding of Firepath, please go through the following link:

    http://www.toolsqa.com/selenium-webdriver/xpath-firebug-firepath/

    If you still face the issue, please send us the screenshot of the element and its html code.

    And do not forget to mark your question as ANSWERED.

    Regards,
    Lakshay Sharma

    Professor Answered on August 22, 2014.
    Add Comment

    Hi Vaidy ,

    There also everywhere they are using Select class for solving the problem , but here Select class will not work as the element is in td tag . Its html code is as follows : –

    <td title=”Search” class=”text-button” noWrap=”” itemID=”emx392066584685.918″>

    The error i am getting after using Select class is as follows:-

    WebElement should be Select but was td.

    Is there any other way which does not use Select class and will perform this  action .

    Regards .
    Sajal

    Train Answered on August 22, 2014.
    Add Comment

    Hi Lakshay,

    I have tried that also .. but it is not working as i am unable to find the further xpath after clicking on the item .

    Following is the HTML code of the element , Please help me it this …

    <td title="Search" class="text-button" noWrap="" itemID="emx1323663590559.1252">
     Text - Search
     <img align="absMiddle" src="http://lgepdm.lge.com/ematrix/common/images/utilNavMenuArrow.gif" border="0"/>
    

    For selecting the element . i have used the following xpath :-

    "//td[@title='Search']"
    
    and it is working fine . But now i am unable to find the xpath of options inside it as the options are called by javascript and it id not present in HTML code .

    Javascript code of the item , i want to click is : –

    var currentToolbarObj = eval(objMainToolbar);
     var ENCCreatePartActionsmxcommandcode = eval();
     tempMenuItem = new emxUIToolbarMenuItem(emxUIToolbar.TEXT_ONLY, "", "Part...", "javascript:showNonModalDialog(\"/ematrix/item/part/CreatePartFirstPage.pdm\",\"924\",\"668\",true )","popup", "", "ENCCreatePartActions","Part...", "toolbar", "924","668", "EngineeringCentral", true,"","","ENCCreatePartActions");tempMenuItem.setMode("");tempMenuItem.setRMB("false");objMenu.setRMB("false");objMenu.addItem
    (tempMenuItem,false);

    PLEASE TELL ME WHAT TO DO NOW … ITS BEING LIKE A BLOCKER FOR ME ..

    Train Answered on August 25, 2014.
    Add Comment

    Hi sajal,

    Please find the below sample code for executing any actions in page with out taking the xpath for element….

    package com.javascript;
        import org.junit.Test;
        import org.openqa.selenium.JavascriptExecutor;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.firefox.FirefoxDriver;
        public class JavaScriptDemo {
        @Test
        public void javascript(){
        WebDriver driver=new FirefoxDriver();
        driver.get("http://www.flipkart.com/");
        String jsQuery="get_detail_banner_popup(null, 'cart-tab');return false;";
        JavascriptExecutor jse=(JavascriptExecutor)driver;
        jse.executeScript(jsQuery).toString();
        }
        
        

    RE: How to select an option of a javascript dropdown which is having no element for its options …

    }

    Html page source will be:

     

    <div class="unitExt cartContainer">
    <div class="cart-btn-cont">
     <a class="btn btn-blue btn-cart" href="/viewcart" onclick="get_detail_banner_popup(null, 'cart-tab');return false;"></a>
     </div>
    </div>
    

     

    I think, it’s help you,

    If you still face the issue, please send us the screenshot of the element and its html code.

    Thanks,
    P V Sivaprasad

    Train Answered on August 26, 2014.

    Hi Siva Prasad,

    Many thanks for helping ToolsQA and we welcome you here, please keep posted your answers.

    Regards,
    Lakshay Sharma

    on August 26, 2014.
    Add Comment

    It is working . Thanks a lot P V Sivaprasad  …

    Train Answered on August 26, 2014.
    Add Comment

    Hi Lakshay,

    Thanks for this Forum, it’s helping lot…for All……….

    Thanks,
    P V Sivaprasad

    Train Answered on August 26, 2014.
    Add Comment

    Hi Siva prasad,

    here also I am facing same issue but i don’t have
    onclick=<strong>"get_detail_banner_popup(null, 'cart-tab');return false;"</strong>></a>
    in my HTML code.

    please find the attached image of our HTML code for your reference.

    RE: How to select an option of a javascript dropdown which is having no element for its options …

    Thanks in Advance.
    Uday Reddy.S

    Train Answered on December 30, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.