RE: Advise on location elements on a webpage I am buildong a selenium script for

Answered

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’

RE: Advise on location elements on a webpage I am buildong a selenium script for

)¬†which highlights what I am trying to do….I thought the best way to do this would be via xpath, as there wasn’t a great deal of information to work off in terms of elements. I’ve attached the HTML from the webpage (Screenshot 2, which hopefully gives an idea of how I built my test scripts in Selnenium.

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

RE: Advise on location elements on a webpage I am buildong a selenium script for

RE: Advise on location elements on a webpage I am buildong a selenium script for

arrive at a page, using the above selenium code, the focus is still on the option I have selected from the menu e.g. ‘Terminated Report: Completed’. This prevents me from being able to select any elements on the page, and I can’t see any way around this. Is there an action whereby the focus can be switched to the webpage as a whole, so I can complete any actions I need to.

Apologies for the long-winded questions, but I just wanted to make sure I explained it all correctly. Any help would be greatly appreciated.

Andy

tilston1001 Train Asked on November 19, 2014 in Selenium WebDriver.
Add Comment
5 Answers

I’ve now managed to work this out, by writing the below code:

public static void barChartSelector(InternetExplorerDriver driver)
{
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement parent = driver.findElement(By.className(“highcharts-series-group”));
List<WebElement> children = parent.findElements(By.tagName(“rect”));
children.get(0).click();
}

Many thanks for your help

Andy

Train Answered on November 24, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.