I am in the process of creating an automated test script using Selenium Webdriver and Cucumber for my company's website. To get started, I utilized Matt-B's example as a foundation. After obtaining the necessary files, I made adjustments to the google.feature file:
Feature: Changing Pages
As an internet user
In order to move through a website
I want to be able to click a button and go to another page
Scenario: Digital3rd Testing page
Given I am on the Digital3rd website
When I click the "Testing" button
Then I should go to "../testing"
I have now begun modifying google-steps.js as follows:
'use strict';
var expect = require('chai').expect;
module.exports = function() {
this.World = require('../support/world.js').World;
this.Given(/^I am on the Digital(\d+)rd website$/, function (arg1, callback) { //declaring function that relates to Cucumber Script
this.driver.get('http://www.Digital3rd.org'); //open intended website
callback(null, 'set-up');
});
this.When(/^I click the "([^"]*)" button$/, function (arg1, callback) { //declaring function that relates to Cucumber Script
this.onload = //when the page loads...
this.driver.manage().window().maximize(); //maximise the screen...
this.driver.findElement({id: 'menu-item-24'}).click(); //click the "Testing" button.
callback(null, 'test');
});
this.Then(/^I should go to "([^"]*)"$/, function (promise) {
var wbaddrss = this.driver.getCurrentUrl();
return expect(wbaddrss).to.contain('/testing');
});
};
The initial steps are functioning correctly by opening the website, maximizing it, and clicking the button. I am currently working on validating that I have landed on the correct page based on a section of the URL. If anyone has suggestions on fixing the "TypeError: obj.indexOf is not a function" or providing an alternative solution, I would greatly appreciate it. Apologies if this is a straightforward fix, as this is my first time working on something like this.
The complete error message displayed in the console is:
TypeError: obj.indexOf is not a function
at Assertion.include (C:\Users\User\Test program\node_modules\chai\lib\chai\core\assertions.js:228:45)
at Assertion.assert (C:\Users\User\Test program\node_modules\chai\lib\chai\utils\addChainableMethod.js:84:49)
at World.<anonymous> (C:\Users\User\Test program\features\step_definitions\google-steps.js:32:30)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)