RE: Advise on location elements on a webpage I am buildong a selenium script for
Hi there, I am after some advice regarding a Selenium script I am building. As can be seen from the screenshot attached I am hovering over the ‘Reports’ text from the navigation pane which brings up a menu…..from there I am selecting ‘Asset Management’, then ‘Terminated Report: Completed’ from the sub-menu.
I’ve also attached the code (‘Selenium Code’
The issue I have had is that, as can be seen from Screenshot 1, I want to arrive at Asset Management > Terminated Report: Completed. After I have checked that page I want to go to Asset Management > Terminated Report: Pending. However, the XPath when selecting the ‘Asset Management’ option is now different, even thought the selection of it is the same as before. I’m assuming this is because I am selecting it from a different page. Based on the above, I have two questions which I am hoping for assistance on:
1) Given that it looks like XPath isn’t the best way of me navigating through this navigation menus, what would be the best element locator to use, in order to get to the desired location? Hopefully, the screenshots provide enough detail.
2) Another issue I have is that when I
Apologies for the long-winded questions, but I just wanted to make sure I explained it all correctly. Any help would be greatly appreciated.
Thanks for the response, Laksh. Now I’ve re-run the selenium test I reckon the issue is to do with the element I am trying to select from the ‘Terminated Report: ‘Completed’ page. I’ve attached a screenshot of the page below; as you can see, there is a bar graph on the page…..for my test I want to select one of the bars which will then open up other functionality on the page. However, I am still having the problem where the focus is on the text from the drop-down, BUT……when I select another element from the page, e.g. the ‘Update Report’ button I am able to do so successfully. This suggests that there may be an issue with selecting functionality from the bar graph. It’s a bit odd as when I open up this page manually, I click on the bar graph once and it carries out the desired action…..however, when I use Selenium and click on the bar graph it doesn’t allow me to select it. As mentioned earlier, the focus remains on the drop-down option so this may be causing the issue, but it didn’t cause any problems when clicking on ‘Update Report’, which is a bit odd.
I’ve also attached the code I have written when I am trying to attempt to select one of the bars on the graph (see below)
Hope you can help.