Select item fro Button Dropdown List

8 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
    1040 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
    1040 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
    1040 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
    1040 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
     
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!