Select item fro Button Dropdown List

10 posts, 0 answers
  1. Chaitanya
    Chaitanya avatar
    6 posts
    Member since:
    May 2014

    Posted 23 May 2014 Link to this post

        Hi,
    I want to select particular item for the button DropDown list .
    Please suggest me suitable way to select.

    Find.ByXPath<HtmlButton>("/html/body/div/div[2]/div/form/div/div/div/button").Click();

    HtmlOrderedList listitem = Find.ByXPath<HtmlOrderedList>("/html/body/div/div[2]/div/form/div/div/div/ul/li[5]/a");
    listitem.Click();

    Regards,
    Chaitanya
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 27 May 2014 Link to this post

    Hello Chaitanya,

    Thank you for contacting us.

    I am not sure if I understand you correctly. What exactly do you want to click?

    Do you want to click an HtmlButton which opens a drop down and then select an item?

    Please send us a screen shot of the drop down and its DOM tree so I can write you the code.

    Another thing is that we don't recommend using XPath. Even a small change in your application will change the XPath and the test will fail.

    Here is an example code:

    HtmlSelect mySelect = ActiveBrowser.Find.ByName<HtmlSelect>("cars");
    mySelect.SelectByText("Fiat");

    Hope to hear from you soon.


    Regards,
    Boyan Boev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  3. Chaitanya
    Chaitanya avatar
    6 posts
    Member since:
    May 2014

    Posted 27 May 2014 in reply to Boyan Boev Link to this post

    Thank you Boyan ,

    Just want to know more about the difference between Click(); function and MouseClick(MouseClickType,LeftClick);

    Thanking you in anticipation.

    Regards,Chaitanya



  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 27 May 2014 Link to this post

    Hello Chaitanya,

    Click() method invokes the click event of the element directly into the DOM.

    MouseClick() method simulates a real click. It acts in the same way as a real user. It will move the mouse and click the element.

    Hope this helps.

    Regards,
    Boyan Boev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  5. Chaitanya
    Chaitanya avatar
    6 posts
    Member since:
    May 2014

    Posted 27 May 2014 Link to this post

    Hi Boyan,

    Thank for the early reply.
    Please help me with the DOM structure .
    I want to click unorderedlist member CREATE in the following and also what is the best way to iterate from outer div to inner div .

    <div class="aaa">
    <div id="ms">
    <div id="ln" class="open">
    <div id="lne" class="">
    <i class="ffba"></i>
    </div>
    <div class="lni">
    <ul class="fl">
    <li class="sh">
    <h3 data-toggle="collapse" data-target="#list-menu" class="collapsed" id="h3list-menu">
    <div class="cc">
    <i class="ffcd"></i>
    </div>
    List
    </h3>
    <ul id="lm" class="csl">
    <li>
    <a name="">Members</a>
    </li>
    <li>
    <a name="")">Groups</a>
    </li>
    </ul>
    </li>
    <li class="sh">
    <h3 data-toggle="collapse" data-target="#create-menu" class="collapsed" id="h3create-menu">
    <div class="cc">
    <i class="ffcd"></i>
    </div>
    Create
    </h3>
    <ul id="cm" class="csl">
    <li>
    <a name="create-menu">Member</a>
    </li>
    <li>
    <a name="create-menu">Group</a>
    </li>
    </ul>
    </li>
    <li class="sh">
    <h3 data-toggle="collapse" data-target="#affiliates-menu" class="collapsed" id="h3affiliates-menu">
    <div class="cc">
    <i class="ffdm"></i>
    </div>
    Affiliates
    </h3>
    <ul id="affiliates-menu">
    <li>
    <a name="affiliates-menu">Affiliate Types</a>
    </li>
    <li>
    <a name="affiliates-menu">Commission Types</a>
    </li>
    <li>
    <a name="affiliates-menu">Affiliates</a>
    </li>
    </ul>
    </li>
    </ul>
    </div> <!-- .left-nav-inner -->
    </div><!-- #left-nav --
  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 28 May 2014 Link to this post

    Hi Chaitanya,

    As I can see in the DOM tree CREATE along with Member and Group are in a single list item (i.e. the are a single element). It should be also in a separate li.

    The only way how you can find it to locate h3 tag with text content CREATE.

    HtmlControl h3 = ActiveBrowser.Find.ByContent<HtmlControl>("CREATE");
    h3.Click();

    If it in a separate list item (<li>CREATE</li>):

    HtmlListItem createItem = ActiveBrowser.Find.ByExpression<HtmlListItem>("InnerText=CREATE");
    createItem.Click();

    Hope this helps.

    Regards,
    Boyan Boev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  7. Chaitanya
    Chaitanya avatar
    6 posts
    Member since:
    May 2014

    Posted 29 May 2014 Link to this post

    Hi Boyan,

    That doesn't worked.
    i'm getting null value for the h3 as well as for createItem in debug mode (using breakpoint).

    Do i have to go from top to bottom iterating each and every html  element to reach the desired element also do we use app.config file in the project for using Database connections in the project.

    Regards,Chaitanya
  8. Boyan Boev
    Admin
    Boyan Boev avatar
    1072 posts

    Posted 02 Jun 2014 Link to this post

    Hi Chaitanya,

    Are you using the the code against the same html you have sent me. The code works against the code you have sent me (even it has a big amount of validating errors).

    Can you please record a quick video using Jing to demonstrate the exact steps you take? 

    Hope to hear form you soon.

    Regards,
    Boyan Boev
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
  9. Austin
    Austin avatar
    17 posts
    Member since:
    Sep 2015

    Posted 21 Sep 2018 Link to this post

    I wants to click on drop down list icon and select(click values) based on index number, value or visible text.
    I am able to locate element click over it, but not sure how to select value by above criteria. 

    Element drop_down =  Find.ByXPath("//div[@class='k-edit-form-container']//span[@class='k-select']"); 
    ActiveBrowser.Actions.Click(drop_down); // click and opens drop down

    drop_down.selectByText("company") // not working.

    what is the proceedure to acheive it with test studio. 
  10. Elena
    Admin
    Elena avatar
    1155 posts

    Posted 21 Sep 2018 Link to this post

    Hello Austin,

    Thank you for reaching us out. 

    Probably the list with items which the drop down contains appears dynamically in the DOM tree when the drop down is toggled. To update the current state of the DOM during execution you will need to refresh it. Please try inserting the following line of code between the toggle action and the one which selects the item from drop down: 

    this.ActiveBrowser.RefreshDomTree();

    Alternatively, if the SelectByText is still not working, you could try to locate the element to select in the DOM tree - it will probably be a ListItem with certain text content - and directly click on it. 

    In case you will need further assistance, please share the DOM tree of the page with drop down at the moment when that is opened to select an item. 

    Thanks in advance! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top