mercredi 26 septembre 2018

Forcing input of an element through Java Script and Robot Framework

I'm trying to test a checkout page that contains credit card details. I'm using Robot FrameWork in pycharm to write automation scripts. A simple ; Input text Xpath doesn't really work

The error that I get is something like this in the log file that's generated after I run my automation script.

KEYWORD Selenium2Library . Capture Page Screenshot 11:24:11.934 INFO Typing text '4111 1111 1111 1111' into text field 'id=card-number-element'. 11:24:12.294 FAIL InvalidElementStateException: Message: invalid element state: Element must be user-editable in order to clear it. (Session info: chrome=69.0.3497.100) (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 x86_64)

SO, I thought an alternative approach would be to inject the card number using JAVA Script. May I know how I can be able to do that? Execute Javascript document.evaluate(' ${loc_credit_card_num}', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).value = "4111 1111 1111 1111" This is what I thought was the right way, but doesn't really work

Aucun commentaire:

Enregistrer un commentaire