List item not selected

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

List item not selected

Post by omayer » Mon Nov 12, 2012 8:07 pm

can't find the item from the drop downlist since to get to the last item needs to be scroll down , tried w/focus, also tried- ListItem item = "/container[@caption='selectbox']/listitem[@text='"+_rateID+"']";
Delay.Ms(3000);
item.Click();

Code: Select all

public void SelectAddRateID(string _rateDDL, string _rateID)
       {
      	
  			bool found = false;
  			bool foundItem = false;
           	WebDocument webDocument = "/dom[@page='index.cfm']";    	
        	SelectTag findRate; 			
			found = webDocument.TryFindSingle(".//select[@id~'pta_.*_cboPayTypeAdditionalID_"+_rateDDL+"']", 30000, out findRate);

				if (!found)  
				{  
				    throw new Ranorex.ElementNotFoundException("SelectAddRateID List was not found", null);                  
				} 
				
				else
				{ 		         
					findRate.Click(Location.CenterRight); 
					Delay.Ms(1000);
					
					OptionTag optItem;
				        foundItem = findRate.TryFindSingle(".//option[@innerText='"+_rateID+"']",5000, out optItem);
					if(!foundItem)
					{
 Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Left); //problem w/scrolling down
            Delay.Milliseconds(4000);
						//findRate.("{Next}");
						optItem.Click();
						Delay.Ms(3000);
					}
					else
					{
					  	optItem.Click();
						Delay.Ms(3000);
						
					}
Tipu

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: List item not selected

Post by Ciege » Mon Nov 12, 2012 9:02 pm

Here is my framework method for selecting a listitem in a DOM Combo Box

Code: Select all

public static int DOMComboSelect(Ranorex.WebDocument webDocumentName, string ComboName, string ComboItem)
{
    /************************************************************************
     * Function         : DOMComboSelect(Ranorex.WebDocument webDocumentName, string ComboName, string ComboItem)
     *
     * Description      : This method will select a ComboBox item in a web document. 
     *                         
     * Parameters       : webDocumentName   - The web DOM object the the ComboBox lives on
     *                  : ComboName         - Name of the ComboBox to click
     *                  : ComboItem         - Item in the ComboBox to select.
     *                  
     * Return Type      : Integer
     * 
     * Return Value     : 0 for success, -1 for failure
     * 
     * Revision History
     * Date       : Author                    : Reason/Change
     * ---------- : ------------------------- : ------------------------------
     * 03/10/2009 : Chris Gendreau            : Initial Creation 
     ************************************************************************/

    Ranorex.SelectTag DOMCombo;

    //Search for the ComboBox on the page
    try
    {
        webDocumentName.EnsureVisible();
        Thread.Sleep(500);
        DOMCombo = webDocumentName.FindSingle(".//select[@Id='" + ComboName + "']");
    }

    catch (RanorexException e)
    {
        Report.Error("Unable to find ComboBox: " + ComboName);
        Console.WriteLine(e.ToString());
        Report.Screenshot();
        return -1;
    }

  //REMOVED A VERIFICATION CALL TO ANOTHER METHOD

    //Click a ComboBox & Item
    try
    {
        Report.Info("Selecting item: " + ComboItem + " in  ComboBox: " + ComboName);
        DOMCombo.EnsureVisible();
        DOMCombo.Focus();
        Thread.Sleep(1000);
        DOMCombo.Click(Location.CenterRight, 1000);
        Thread.Sleep(1000);
        ListItem item = "/container[@caption='selectbox']/listitem[@text='" + ComboItem + "']";

        if (item.Visible == false)
        {
            Keyboard.Press("{HOME}");
            Thread.Sleep(500);
            while (item.Visible == false)
            {
                Keyboard.Press("{PageDown}");
                Thread.Sleep(500);
            }
        }

        item.Click(Location.Center, 1000);
        Report.Debug("  Selected item: " + ComboItem + " in  ComboBox: " + ComboName);
    }

    catch (RanorexException e)
    {
        Report.Error(e.ToString());
        Report.Screenshot();
        return -1;
    }

    return 0;
} //End DOMComboSelect
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: List item not selected

Post by omayer » Mon Nov 12, 2012 9:45 pm

Thank you again and again Ciege, it worked
Tipu

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: List item not selected

Post by Ciege » Mon Nov 12, 2012 11:35 pm

Welcome... Glad it worked for you.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...