GXtest UI Commands - Browser

Official Content
This documentation is valid for:

TakeScreenshot

TakeScreenshot_png

Captures a screenshot of the page and saves it to an image file. If the file already exists, it is overwritten. This function will use the value of the  Full Page Screenshot property in order to determine wether to take a screenshot of the viewport or the whole page.

Parameters:

  • filePath: an absolute or relative path to the file to be saved. 
  • imageFormat: It is recommended to use PNG format always (imageFormat = 0)
    • 0 - png (java and .net)
    • 1 - jpg (only for .net)
    • 2 - gif (only for .net)
    • 3 - tif (only for .net)
    • 4 - bmp (only for .net)

fullPageScreenshotOverload_PNG

Captures a screenshot of the page and saves it to an image file. If the file already exists, it is overwritten. With the third parameter the user has the possibility to define wether or not a full page screenshot will be taken, overriding the property defined behaviour.

Parameters:

  • filePath: an absolute or relative path to the file to be saved. 
  • imageFormat: It is recommended to use PNG format always (imageFormat = 0)
    • 0 - png (java and .net)
    • 1 - jpg (only for .net)
    • 2 - gif (only for .net)
    • 3 - tif (only for .net)
    • 4 - bmp (only for .net)
  • fullPage: wether to take the screenshot as full page or not

Examples of use: 

&driver.TakeScreenshot("../photos_wp.png", 0)

&driver.TakeScreenshot("../photos_wp.png", 0, true)

If you need, take a look at the implementation example to not overwrite the screenshots for the different executions of the same test.

GetSource

image_2018125143551_1_png

Gets the source HTML code of the current webpage. 

Returns: The webpage source-code as a string

Example of use: 

&wp_source = &driver.GetSource()

 

GetTitle

image_20181251642_1_png

Gets the current webpage title. 

Returns: The webpage title as a string

Example of use: 

&wp_title = &driver.GetTitle()

 

Maximize

image_201812516637_1_png

Maximizes the browser window. 

Example of use: 

&driver.Maximize()

 

SetWindowSize

SetWindowSize_2020929133630_1_png

Sets the browser's exact window size. 

Parameters:

  • Width: window width in pixels
  • Height: window height in pixels

Example of use: 

&driver.SetWindowSize(720, 480)

 

Go

Go_Command_png

Navigates to the given URL.

Parameters:

  • url: target URL to navigate to, it can be full or partial. In case it is partial it will be combined with the Base URL property.

Example of use:

&driver.Go(WebPanelX.Link())

&driver.Go("https://abstracta.us/why-us/company")

 

SetBaseURL

SetBaseURL_Command_png

Sets a base URL to be used when relative paths are given to Go commands. This is automatically set if you have configured the BaseURL property on your environment.

Parameters:

  • url: the base URL to be set. It will be combined with the url parameter of Go commands.

Example of use:

&driver.SetBaseURL("https://serverName/applicationName/")

 

Refresh

image_201812516745_1_png

Refreshes (reloads) the browser webpage. 

Example of use: 

&driver.Refresh()

 

GoBack

image_2020929134347_1_png

Goes to the previous page 

Example of use: 

&driver.GoBack()

 

GoForward

image_2020929134423_1_png

Goes to the next page. Note that it is required to perform a GoBack command in order for this command could be used.

Example of use: 

&driver.GoForward()

 

ScriptEval

image_201812516943_1_png

Runs JavaScript code.

Parameters:

  • Script: a string containing the JavaScript code to run. 

Returns:

  • Script's returned value.

Example of use: 

//Change Title to "New Title" using Javascript
&driver.ScriptEval("document.title = 'New Title';")

// Get last status code
&statusCode = &driver.ScriptEval("return window.gx.http.lastStatus")

Notes: JS functions are intended for some specific automation that (for some reason) is it not possible to achieve using traditional UI commands, so this is intended to be used only by experienced users.