Ranorex Help Center How can we help you?

Web Testing

The Ranorex Web Plugins (for Microsoft Internet Explorer, Mozilla Firefox, Google Chrome and Chromium) allow you to test the UI of web applications in the same way you would automate standard desktop applications.


Note If you want to run tests on other OS and browser combinations, our Selenium WebDriver Integration is what you're looking for.




Architecture of Websites in the Ranorex Framework

Ranorex is able to access the complete HTML architecture of a web document. Use the Ranorex Spy to analyze the structure and the content of a web application and to see which information is accessible during automation.

All open websites are shown as a single Dom node in the spy tree. In addition to standard browser hosted applications, Ranorex is able to see embedded browser objects too (e.g. compiled help files). Additional each tab item within a browser window is presented as a separate Dom node within the spy tree.

Representation of websites

Representation of websites



RanoreXPath example

RanoreXPath example



The web document and its HTML structure can be identified using RanoreXPath. Similar to XPath in HTML, the RanoreXPath provides a simple search mechanism for finding single or multiple web elements within a web page.

WebDocument Adapter

The WebDocument Adapter creates a representation of the complete web-site including all tags (e.g. the header tag, body tag, etc.). Furthermore it offers useful ways to make your test scripts more effective.

The following sample shows how to use these features:

// Identify a web document by its title  
WebDocument webDocument = "/dom[@caption='Ranorex Test Page']";  
// Open a website  
webDocument.Navigate("http://www.ranorex.com");  
// Wait until the document is loaded  
webDocument.WaitForDocumentLoaded();  
// Execute a javascript code  
webDocument.ExecuteScript("history.back();");  



' Identify a web document by its title  
Dim webDocument As WebDocument = "/dom[@caption='Ranorex Test Page']"  
' Open a website  
webDocument.Navigate("http://www.ranorex.com")  
' Wait until the document is loaded  
webDocument.WaitForDocumentLoaded()  
' Execute a javascript code  
webDocument.ExecuteScript("history.back();")  



Find or filter Web Elements

The Ranorex Framework offers a wide range of adapters for each HTML tag elements (e.g.: ATag adapter for <a> tags). Each adapter has specific methods and attributes; the link tag (<a>) for example has additional attributes like HREF, TARGET and REL.

// Start IE with a specific website  
System.Diagnostics.Process.Start("iexplore.exe",  "www.ranorex.com/web-testing-examples");  
// Identify the webdocument by its title  
WebDocument webDocument = "/dom[@caption='Ranorex Test Page']";  
// Find a link by its link text (innertext)  
ATag link = webDocument.FindSingle(".//a[@innertext='simple link']");  
link.Click();  



' Start IE with a specific website  
System.Diagnostics.Process.Start("iexplore.exe", "www.ranorex.com/web-testing-examples")  
' Identify the webdocument by its title  
Dim webDocument As WebDocument = "/dom[@caption='Ranorex Test Page']"  
' Find a link by its link text (innertext)  
Dim link As ATag = webDocument.FindSingle(".//a[@innertext='simple link']")  
link.Click()  



Cross-Browser Testing

During the installation of Ranorex the setup package automatically installs add-ins for all supported browsers, which enable the communication between the Ranorex Browser Plug-In and the specific browser. If you have problems with instrumenting a specific browser use the Ranorex Instrumentation wizard as explained here.

Creating tests for Firefox does not differ to creating tests for Internet Explorer or any other supported browser. All web UI elements are specified through RanoreXPath, which uses HTML attributes and values for identification. For this reason a single web repository can be used for testing all supported types of web browsers. Learn more about how to test multiple browsers with a test case based on one single repository introduced by our web testing example project, which is part of the Ranorex setup package.

Automation of browser specific elements (e.g. Pop-Up window)

Handling of browser specific UI controls requires a separate RanoreXPath for each browser specific element. That means if you would like to click on a Pop-Up dialog in different browser, you will have to add a separate repository item for each dialog.

The Ranorex Automation library provides you with a property called 'BrowserName' which tells you the current browser of the web site under test:

// Click the OK button in popping up dialog of one of the supported browser  
// If the current browser is Internet Explorer  
if(webDocument.BrowserName == "IE")  
{  
    Button okIE = "/form[@processname~'(iexplore|IEXPLORE)']//button[@text='OK']";  
    okIE.Click();  
}  
// If the current browser is Mozilla Firefox  
else if(webDocument.BrowserName == "Mozilla")  
{  
    Button okFF = "/form[@processname='firefox']//button[@text='OK']";  
    okFF.Click();  
}  
// If the current browser is Google Chrome  
else if(webDocument.BrowserName == "Chrome")  
{  
    Button okChrome = "/form[@processname='chrome']//button[@text='OK']";  
    okChrome.Click();  
}  
// If the current browser is Apple Safari  
else if(webDocument.BrowserName == "Safari")  
{  
    Button okSafari = "/form[@processname='Safari']//button[@text='OK']";  
    okSafari.Click();  
}  



' Click the OK button in popping up dialog of one of the supported browser  
' If the current browser is Internet Explorer  
If webDocument.BrowserName = "IE" Then  
    Dim okIE As Button = "/form[@processname~'(iexplore|IEXPLORE)']//button[@text='OK']"  
    okIE.Click()  
' If the current browser is Mozilla Firefox  
ElseIf webDocument.BrowserName = "Mozilla" Then  
    Dim okFF As Button = "/form[@processname='firefox']//button[@text='OK']"  
    okFF.Click()  
End If  
' If the current browser is Google Chrome  
ElseIf webDocument.BrowserName = "Chrome" Then  
    Dim okChrome As Button = "/form[@processname='chrome']//button[@text='OK']"  
    okChrome.Click()  
End If  
' If the current browser is Apple Safari  
ElseIf webDocument.BrowserName = "Safari" Then  
    Dim okSafari As Button = "/form[@processname='Safari']//button[@text='OK']"  
    okSafari.Click()  
End If  



Recordings & Repositories

Ranorex Recorder provides the same capture and replay functionality, which is used for standard client desktop applications. The recorder automatically creates action items for each recorded user action within the Recorder's actions table. The corresponding repository contains all required UI web element objects used within the actions table.

Web based recording

Web based recording



Repositories and the WebDocument

The following example shows how to access the methods of the WebDocument using a repository:

// Load repository  
ProjectRepository repo = ProjectRepository.Instance;  
// Open a website  
repo.WebPage.Self.Navigate("http://www.ranorex.com");  
// Wait until the document is loaded    
repo.WebPage.Self.WaitForDocumentLoaded(); 



' Load repository  
Dim repo As ProjectRepository = ProjectRepository.Instance  
' Open a website  
repo.WebPage.Self.Navigate("http://www.ranorex.com")  
' Wait until the document is loaded    
repo.WebPage.Self.WaitForDocumentLoaded()