Skip to main content

Posts

Showing posts with the label nodejs

Waiting for values to finish loading on the page with WebdriverIO

There are many automated tests where you have to wait for certain fields to finish loading actual values on the web page before proceeding to the next verification point. You can see an example of such test below. At first, let’s implement a new method of the OrderPage class (we use a very simple page-object model here). This class also includes another method to open the page and element locators as getters. browser is a global WebdriverIO object that allows you to interact with the pre-initialized web browser of your choice. I used “wdio-chromedriver-service” to start Google Chrome, but you can use a different service. waitForMarketValuesToLoad method is waiting for the required fields to load the real values which are not the dashes (-). As you could probably guess, the dashes are loaded immediately upon opening the page and then the real values slowly start to appear, it can take several seconds to load values in those 4 fields. You can also add regular expressions to check t

Integrating TestRail and Gitlab CI/CD

Perhaps you are using Gitlab CI/CD at your project. Every project requires some test cases for regression testing, and Gitlab actually provides this feature, but it’s only available in Ultimate version that is more expensive. TestRail is another popular platform for managing your test suite that provides way more extensive capabilities and options than Gitlab’s own test case management feature. So the chances are that you are still willing to use TestRail for your acceptance and regression testing efforts. Why not combining the best of two worlds — the flexibility of Gitlab CI/CD and rich test case management capabilities of TestRail? In the following example I’ll demonstrate how this goal could be achieved with ease. Let’s assume that we need to create a new Milestone in TestRail that contains two test runs — the one with Acceptance tests, and another one with Regression tests. The step in your .gitlab-ci.yml Gitlab configuration file would look like this: This step is reading CI

How to add Coded Ignore Regions dynamically in Applitools

There is a special feature in in Applitools Eyes that's called "coded ignore regions" to handle dynamic data. It's often used in Strict mode to increase test coverage if you don't want to switch to Layout mode. You can add coded ignore regions to the screenshot like this: target = target.ignore(By.id('reg1')).ignore(By.id('reg2')).ignore(By.id('reg3')); But what if these elements are created dynamically and you don't know how many of them will appear on the page? There could be 5 elements, or maybe 100... You cannot just add them in a chain by modifying a target like that. The answer is - you have to count them first and then add them in a loop. You can see the complete solution below for JavaScript.

Basic setup and configuration of TestObject in Node JS for testing of a web application

If you are already using SauceLabs for automated web UI testing on mobile devices, then you could be interested in trying TestObject cloud service that was acquired and became a part of SauceLabs family in 2017. It allows you to run your existing tests on real devices (Android and iPhone). SauceLabs provides emulators, which work quite well, but, depending on the requirements of your project, you may need to execute tests on real hardware. Another reason for switching to TestObject could be using the latest version of Android OS which may not be available at SauceLabs. At the moment of posting this article the latest supported version was Android 7.1 on SauceLabs and Android 8.1 on TestObject. Luckily the transition to TestObject is quite seamless. You don't need to modify your existing automated tests, only the provider endpoint and a few capabilities. The disanvantage of using a free Testobject account is that you are limited to only a few devices which are marked as Free in th

Annotating Sauce Labs tests in Node JS

SauceLabs does not annotate jobs by default, showing the question marks instead of statuses, and the name of a job is always set to "Unnamed job". Luckily we have all the powers of Sauce Labs REST API in our hands and can both set the name of a job and its final status to something more meaningful. This example demonstrates how it can be done in Node JS. Every Sauce Labs job has a unique ID. We get this ID from the Webdriver object. saucelabs.js main.js

Reading a Gitlab pipeline variable in NodeJS synchronously

I'm assuming you already created your project on Gitlab and got your personal access token . This is a simple synchronous function that reads a Gitlab pipeline variable in NodeJS using Gitlab REST API v3. It uses sync-request that is not recommended to use in a production environment, although it can be successfully used in automated testing and various scripts.