List of keywords - Selenium JavaScript Keywords

To learn how to use Selenuim JavaScript keywords in Opkey, you can read Using Selenium JavaScript Keywords - New UI and Using Selenium JavaScript Keywords - Opkey Classic

 

Now let's go through the list of various web keywords:

SetViewPort

This keyword sets the Page Layout according to the given dimensions. It is used to open any website/browser in the Mobile View.


Example


Suppose you want to set the Page Layout according to the given dimensions, then you can use the SetViewPort keyword as follows:


SetViewPort

Width

412

Height

732

Browser with Width “412” & Height “732”


Test Object 


Test Object Required

Description

None

This keyword does not require any Object input argument.


Input Data

 Input Data Required

 Description 

Width

 

* It is of Integer type.

* It takes the width of the page.

Height

* It is of Integer type.

* It takes the height of the page.


Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False



Common Error conditions

Scenarios

Error Message

Debug Information

If the Data Input Argument is not given

Argument Data Missing

 

Argument(s): (Width; Height) is/are blank.



3. ValidatePageAccessibility

This keyword validates the Page Accessibility at run time and will generate an Accessibility Report which contains the required page Accessibility.


Test Object 


Test Object Required?

Description

No

This keyword does not require any Object input argument.


Input Data

 Input Data Required?

 Description 

No

This keyword does not require any Data Input argument. 


Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False



Error conditions


There are no error conditions for this keyword.

.

4. VisualCheckPointsForObjects

This keyword takes the objects and test the location of the objects relatively to each other on a page. This keyword creates and compare different layout among different objects.

This keyword will take minimum of 10 objects. 

Example

Suppose you want to takes the objects and test the location of the objects relatively to each other on a page then, here is how you will use VisualCheckPointsForObjects keyword.


VisualCheckPointsForObjects

SpecFile Name

LIFE

SpecFolder Path

xls

 

Test Object 


Test Object Required?

Description

Object (1-10)


This keyword requires an Object as an object input argument.

Note: You can Provide 10 Objects at a time with this keyword


Input Data

 Input Data Required?

 Description 

SpecFileName

* It is of String type.

* It takes the name of the Spec (Objects) file.

* It is created once.

 

SpecFolderPath

* It is of String type.

*It takes the path(location) where SpecFile will be saved after creation.

 



Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False




Error conditions

Conditions

Error Message

Debug Information

If no object is provided

Argument Data Missing

 

Data not provided for argument:'Object1; Object2; Object3; Object4; Object5; Object6; Object7; Object8; Object9; Object10'. Expected StaticValue was empty

 

5. VisualCheckPointsForPage

VisualCheckPointForPage keyword is basically used to compare a page with the already captured same page at runtime.

This keyword compares the page image by breaking image into given numbers of rows and columns.

This keyword when run for the first time will capture the current page snapshot and then the snapshot  will be compared with the same page when it will run for the second time. If there will be any differences, it will highlight the area of differences.

Example

Suppose you want to compare a page with the already captured same page at runtime then, here is how you will use VisualCheckPointForPage keyword.

VisualCheckPointForPage

Image

Name

XYZ

Should

Overlay

False

Number

OfRows

 

20

NumberOf

Columns

20

Test Object 


Test Object Required?

Description

No

This keyword does not require any Object input argument.


Input Data

 Input Data Required?

 Description 

ImageName

* It is of String type.

* It takes the name of the image to be captured.

 

ShouldOverlay

* It is of Boolean type.

* By default it is False.

* If it is False, it will highlight the image with Red dotted lines.

* If it is True, it will highlight the image with Green overlay.

 


NumberOfRows

* It is of Integer type.

* It is the number of rows in which image will be divided.

* By default, number of rows are 10.

 


NumberOfColumns

* It is of Boolean type.

* By default it is False.

* If it is False, it will create the Spec(Objects) File.

* If it is True, it will compare the Specs(Objects) and will create a Visual QA Report.



Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False



Error conditions


There are no error conditions for this keyword.

 

6. VisualCheckPointSetting

This keyword sets prerequisites for the Visual QA. It takes the required settings need to perform the Visual QA on responsive websites.


Example

Suppose you want to sets prerequisites for the Visual QA then, here is how you will use VisualCheckPointSetting keyword.

VisualCheckPointSetting

SpecFile Name

ABC

SpecFolder Path

Platform

Desktop

ValidateBaseline

False

Approximation Range

10


Test Object 


Test Object Required?

Description

No


There was not requirement of object data argument


Input Data

 Input Data Required?

 Description 

SpecFileName

* It is of String type.

* It takes the name of the Spec (Objects) file.

* It is created once.

 

SpecFolderPath

* It is of String type.

*It takes the path(location) where SpecFile will be saved after creation.


Platform

* It is of String type.

* It takes the view(platform) on which a particular script has to be executed.

* Platform can be Mobile View or Desktop View.


Validate Baseline

* It is of Boolean type.

* By default it is False.

* If it is False, it will create the Spec(Objects) File.

* If it is True, it will compare the Specs(Objects) and will create a Visual QA Report.


Approximate Range

* It is of Integer type.

* It takes the approximate value upto which errors can be ignored.




Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False




Error conditions


Conditions

Error Message

Debug Information

If no object is provided

Argument Data Missing

 

Argument(s): (SpecFileName;

Platform;

SpecFolderPath; ValidateBaseline; Approximation

Range) is/are blank




7. LoadSeleniumJS

This keyword is used to load the OpKey Selenium-JS plugin at runtime which is to be used for the Test Execution. This keyword is generally used when you have a Test Case which has all Generic keywords along with few Selenium-JS keywords which are Selenium-JS specific. This keyword is doesn’t take any object or data input argument.

Example: 

Suppose there is a Test Case which has both mobile & web test steps. In such case, you need to load both plugins (OpKey Mobility & Selenium-JS plugins) at runtime so that they can be used for executing respective test steps, as required.

You need to add this keyword (LoadSeleniumJS) with a test step, just before stating the Web flows. Save the test case and then click on Run Now. It will take few moments to load the required plugins (as per the added test steps). There will be a popup message regarding the loaded plugins which will be used for executing the test case.


Test Object 


Test Object Required?

Description

No

This keyword does not require any Object input argument.


Input Data

 Input Data Required?

 Description 

No

This keyword does not require any Input data argument. 


Output Data

Condition

Output value

If the keyword passes successfully

True

if there is an error

False

Error conditions


Conditions

Error Message

Debug Information

When keyword “LoadSeleniumJS” is not added to the Test Step.

Oops! Seems like ‘SeleniumJS' is not added in your package or not installed with the agent. Kindly contact OpKey Support Team at support@opkey.com for assistance.

Oops! Seems like '‘SeleniumJS' is not added in your package or not installed with the agent. Kindly contact OpKey Support Team at support@opkey.com for assistance.

 

To learn how you can use these keywords in test scenarios, you can visit https://university.opkeylms.com and enroll in our Opkey series course.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article