Is it possible to set the value of Style property of an element by nightwatch.js ? if yes then how?

I am working with nightwatch.js and i am quite new into this automation testing, i want to set the value into the style property of an element by nightwatch.js, so i am asking, is it possible ? if it is possible then how can we implement it.

I can access the style property values and can check by following nightwatch api command but i couldn't find any way to set the style's value to an element using nightwatch.js

browser.expect.element('#main').to.have.css('display').which.equals('block');

Answers:

Answer

You can use the Nightwatch Selenium execute protocol to change the style property of an element. With the Selenium execute protocol you can execute arbitrary javascript on the site to be tested.

For example you can use it like this:

browser
.execute("document.getElementById('main').style.display = 'block';")
.expect.element('#main').to.have.css('display').which.equals('block');

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.