Hi Fran,
-
one option if you are really set on useing that java script would be to use the Execute JavaScript keyword to call the buttonTest function
-
some another options would be not bother with javascript and just use the existing Browser Library keywords to test the button
Assuming the XPATH //button[contains(@class, 'app-pay-button')]
will select the button regardless of whether the button is active or not then you could do this:
${payButtonClasses}= Get Attribute //button[contains(@class, 'app-pay-button')] class
Should Contain ${payButtonClasses} form-is-valid
but you could potentially do the entire test with a single keyword by using a more complex XPATH like this which will fail if the button doesn’t have both classes:
${payButtonClasses}= Get Attribute //button[contains(@class, 'app-pay-button') and contains(@class, 'form-is-valid')] class
or even by using the Get Attribute assertion arguments
${payButtonClasses}= Get Attribute //button[contains(@class, 'app-pay-button')] class contains form-is-valid
All three of these are possibly easier to use and to read/understand (for future testers maintaining your tests)
Hope this helps,
Dave.