Back button on browser not recognized on Selenium endpoint

Best practices, code snippets for common functionality, examples, and guidelines.
sgcneil
Posts: 1
Joined: Wed Jun 12, 2019 9:26 am

Back button on browser not recognized on Selenium endpoint

Post by sgcneil » Wed Jun 12, 2019 10:03 am

I have created an automated test on a website using my local machine as the Endpoint and it recognizes pressing the browser's Back button.
However when I set Selenium Webdriver as the endpoint, Ranorex cannot find the back button and the testing fails there.
I have many "back" button presses in my Test Suite to thoroughly test the website's capacity so I can't just remove that step.

The error message is:
Failed to find item 'xxxxxxxxRepository.WebDocumentxxxxxxxxOn.Self'.
No element found for path '/dom[@domain='xxxx.xxxxe.com']' at step 'dom[@domain='xxxx.xxxxe.com']' after 85 attempts within 30s.

I've seen on the Ranorex report screenshot that the browser's menu bar on top is cropped out and only shows the site's content. I want to know why but I'm more interested on how to execute a back button on browsers when using Selenium as an endpoint.

To summarize the question:
If I want to use Selenium webdriver as an endpoint, how could I execute a command on Ranorex that moves back to the browser's previous page?


OS: Windows10
RanorexStudio:v9.1.0
browser:Chrome (haven't tried on other)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Back button on browser not recognized on Selenium endpoint

Post by odklizec » Thu Jun 13, 2019 3:13 pm

Hi,

As far as I know, Selenium cannot manipulate web browser's UI controls? On Selenium, if you want to navigate back, you must use code like this:

Code: Select all

driver.Navigate().Back();
The question is, how to invoke such command in Ranorex? Maybe this page could help?...
http://scraping.pro/example-of-scraping ... in-csharp/
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Back button on browser not recognized on Selenium endpoint

Post by qwertzu » Fri Jun 14, 2019 6:49 am

Hi,

For executing Selenium commands, you have to fetch the currently used webdriver endpoint with these two lines:

Code: Select all

var webDriverEndpoint = Host.Current.TryGetAsWebDriverEndpoint();
OpenQA.Selenium.IWebDriver driver = webDriverEndpoint.WebDrivers.FirstOrDefault();
Afterwards you should be able to execute Selenium commands as Odklizec suggested.

Also, don't forget to add the necessary "usings" at the top of your code module:

Code: Select all

using System.Linq;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Interactions;

Regards, qwertzu