Forum Discussion

mikileung's avatar
mikileung
Occasional Contributor
4 years ago

Web dropdown menu

Hi, 

 

I am trying to write a script (Python) to 

- click the down arrow button 

- select one of the options in the drop down menu. 

Here is my script. It failed with the log saying "The object does not exist. See Details for additional information."

I am a Python beginner, it would be great if someone can help. 

 

 

def my_test():

p = Aliases.browser.pageLogon.sectionShellSplitCanvas.frameApplicationActivitytypeMana.frameIframeid.textbox_activityTypeCat
p.Click()
my_choice = page.Find("contentText","Manual entry, manual allocation",10,True)
my_choice.Click()

 

 

  • Thanks 

     

    I have changed the p to narrow down the search area. I managed to find the object but now it says There was an attempt to perform an action on a zero-sized window. 

    The drop down list does not hold up, which it is very hard to map the object. That is why I used the find object method. If I map the object with the object spy, it would say the object is not under the object tree. 

     

    Is there a way to solve this problem? 

     

    Here is my adjusted code, 

    def my_test():
    # Find all enabled buttons in the Replace dialog
    p = Aliases.browser.pageLogon.sectionShellSplitCanvas.frameApplicationActivitytypeMana.frameIframeid.activityTypeCat_dropdown_var
    my_choice = p.Find("contentText","Manual entry, manual allocation",2,True)
    if my_choice.Exists:
    Log.Message("FOUND IT!")
    my_choice.Click(-1,-1)
    else:
    Log.Message("Cannot find the menu option")

     

  • BenoitB's avatar
    BenoitB
    Community Hero

    It failed after doing the click ?

     

    Several possibilites:

    - find depth not enough (check object Spy)

    - using xpath

    - sometimes the windows underlying the drow down is not at page level

    - use selectItem or Item(x) or whatever method of this kind linked to dropdown object (check object spy, Methods tab)

     

     

  • mikileung's avatar
    mikileung
    Occasional Contributor

    Thanks 

     

    I have changed the p to narrow down the search area. I managed to find the object but now it says There was an attempt to perform an action on a zero-sized window. 

    The drop down list does not hold up, which it is very hard to map the object. That is why I used the find object method. If I map the object with the object spy, it would say the object is not under the object tree. 

     

    Is there a way to solve this problem? 

     

    Here is my adjusted code, 

    def my_test():
    # Find all enabled buttons in the Replace dialog
    p = Aliases.browser.pageLogon.sectionShellSplitCanvas.frameApplicationActivitytypeMana.frameIframeid.activityTypeCat_dropdown_var
    my_choice = p.Find("contentText","Manual entry, manual allocation",2,True)
    if my_choice.Exists:
    Log.Message("FOUND IT!")
    my_choice.Click(-1,-1)
    else:
    Log.Message("Cannot find the menu option")