Home > Software engineering >  How to click on an element in a list in robot framework
How to click on an element in a list in robot framework

Time:01-13

How can i select settings from this dropdown list. I tried Click Element by(class/id..) but none of them work for me.

First i have to click on the profile icon, then choose the settings element

here is the html code of the icon :

<li  id="yui_3_14_0_1_1641997655918_41561">
                              
                              <a data-toggle="dropdown"  href="javascript:void(0)" id="yui_3_14_0_1_1641997655918_41560">
                              <span  data-toggle="tooltip" data-placement="bottom" title="Profile" id="yui_3_14_0_1_1641997655918_41569">
                              <i aria-hidden="true"  id="yui_3_14_0_1_1641997655918_41940"></i>
                              </span>
                              <b ></b>
                              </a>
                              
                              <ul  id="yui_3_14_0_1_1641997655918_48939">
                                 <li  id="yui_3_14_0_1_1641997655918_48940"><a id="cc_userName">Hamza Touaf</a></li>
                                 
                                 
                                 <!-- <li><a id="userProfile"><i ></i>User Profile</a></li>-->
                                 <li><a id="newUserProfile"><i ></i>User Profile</a></li>
                                 <li ></li>
                                 
                                 <li id="yui_3_14_0_1_1641997655918_48938"><a id="settings" href="/cc/settings.html"><i ></i>Settings</a></li>
                                 <li  id="yui_3_14_0_1_1641997655918_48945"></li>
                                 <!--
                                        
                                    
                                    
                                        <li><a id="businessEntityAccount"><i ></i>My Business Account</a></li>
                                        <li ></li>
                                        
                                    <li><a id="feedback"><i ></i>Feedback</a></li>
                                     -->
                                 <li  id="yui_3_14_0_1_1641997655918_48944"></li>
                                 
                                 <li id="yui_3_14_0_1_1641997655918_48943"><a href="/cc/signoff.html" id="logout"><i ></i>Logout</a></li>
                                 <li  id="yui_3_14_0_1_1641997655918_48942"></li>
                                 
                                 <li id="yui_3_14_0_1_1641997655918_48941"><a id="refresh"><i ></i>Refresh</a></li>
                                 <!--
                                 <li ></li>
                                 
                                 <li><a id="downloadModels"><i ></i>Prepare Offline Models</a></li>
                                 
                                 -->
                                 <!--<li ></li>
                                 
                                    <li hide><a id="changeUI" data-value="0"><i ></i>Switch to Classic UI</a></li>
                                 -->
                                 <li ></li>
                                  
                              </ul>
                           </li>

and here is the element of the list that i want to select :

<li id="yui_3_14_0_1_1641997655918_48938">
<a id="settings" href="/cc/settings.html"><i ></i>Settings</a></li>

Any help please?

CodePudding user response:

This should work. Assuming that the list line element is of profile icon (It was unclear for me from the HTML you pasted, but you may better figure out on your application by inspecting it). If needed be, you may apply a Sleep of 1-2 sec in between the two lines

Click Element       xpath: //*[@title='Profile']
Click Element       id: settings

P.S. I am assuming that you have imported all the required libraries for this (in fact, it is only SeleniumLibrary that is required for these two lines)

  •  Tags:  
  • Related