Closed johnqa closed 1 year ago
Hi @johnqa , TESTAR contains pre-defined methods that allow users to trigger specific actions before starting the Generate-testing loop.
waitLeftClickAndTypeIntoWidgetWithMatchingTag("name","username", "john", state, system, 5,1.0);
waitLeftClickAndTypeIntoWidgetWithMatchingTag("name","password", "demo", state, system, 5,1.0);
waitAndLeftClickWidgetWithMatchingTag("value", "Log In", state, system, 5, 1.0);
Documentation: TESTAR_HandsOn
Sections: Webdriver 8.3 & 8.4
Example of use: 02_webdriver_parabank
Method: beginSequence(SUT system, State state)
Those pre-defined methods execute actions at the GUI level, moving the mouse and using the system keyboard devices. But you can also execute scripted actions to trigger a login if needed.
WdDriver.executeScript("document.getElementsByName('username')[0].setAttribute('value','john');");
WdDriver.executeScript("document.getElementsByName('password')[0].setAttribute('value','demo');");
WdDriver.executeScript("document.getElementsByName('login')[0].submit();");
If none of those triggered action help in your case, maybe because you cannot easily obtain the elements from the DOM.
You can try to execute a pure combination of Keyboard actions that paste the value, play with TABs, and ENTER for login.
new CompoundAction.Builder()
.add(new PasteText("john"), 0.5) //assume keyboard focus is on the user field
.add(new KeyDown(org.testar.monkey.alayer.devices.KBKeys.VK_TAB), 0.5) //tab to change the focus to password
.add(new PasteText("demo"), 0.5) //paste the password
.add(new KeyDown(org.testar.monkey.alayer.devices.KBKeys.VK_ENTER), 0.5).build() //Enter to submit the login
.run(system, null, 2);
Lets us know if some of these approaches help you to log in and start your application in the state you need to test.
If not, an example of your login will help us to find another way.
Regards, Fernando
Thank you very much, your instructions helped me do what I needed.
Best Regards, John
Hi,
I have an app with basic authentication (but not required in the home page so I cannot use https://user:pass@whatever.com) and I cannot generate any tests on it. At the basic authentication dialog it just stops as the popup is not recognised.
Before I was using Recording function to go over the parts I was not interested in, but now I don't have this option anymore.
How can I tackle this?
Thank you, John