Member-only story
Cypress: Parsing through search suggestion text box with Jquery
While writing test script, it might be very difficult for us to get the text from text suggestion box and click the text. Since in Cypress we cannot assign the text value of a tag directly, it becomes more difficult for us to assert and select particular text from the suggested text. For this issue, we will use Jquery to parse through the suggested text and click on the apt one.
Pre-requisite:
- npm
- nodejs
- cypress
Let’s get started:
First thing will be initializing the empty node package manager(npm) with below command after creating a project folder,
npm init -y
Now we may need to install the testing framework Cypress with below command,
npm install cypress
Let’s open the Cypress with below command,
npx cypress open
Test scenario:
Our scenario will be typing “javascript” inside the google search bar and then selecting “javascript basics” from the suggestion bar,