I am trying to set up a class and pass in the user and the password from the test case. I know I am doing something wrong with the variables but I cant figure out how to fix.
The call in the test case CustomKeywords.‘net.Login.login’(‘testuser’, ‘testpass’)
The Class
class Login {
/**
* Login to Staging
*/
@Keyword
def login(String strUserName, String strPass) {
WebUI.openBrowser(‘https://test.com’)
WebUI.setText(findTestObject(‘Page_Net - Home/input_Username_username’), strUsername)
WebUI.click(findTestObject(‘Page_Net - Home/Sign In Button’))
WebUI.setText(findTestObject(‘Page_Net - Login/input_Password_txtPassword’), strPass)
WebUI.click(findTestObject(‘Page_Net - Login/button_Continue’))
WebUI.delay(8)
}
}
It would help a lot if we knew the error…
There is no error the variable just does not get populated
Does any of that code work?
Does the browser go to the correct URL?
Can you print a comment from inside the class method?
What happens if you supply the name/pass combination in the class method?
Robby: That’s FIVE questions I’ve asked instead of giving you one answer. Read the link I sent and act on it. Otherwise I can only assume you don’t really want to have your problem solved.
Does any of that code work? Yes the code works without the variables. Also if I name the strUserName variable to outerTagName it works when calling the class. Is there a reason I have to use outerTagName
Does the browser go to the correct URL? All the code works with and without variables if I name the variable outerTagName
Can you print a comment from inside the class method? Yes when i put a keywordlogger it works fine even with the strUserName Variable… Maybe I need a delay?
What happens if you supply the name/pass combination in the class method? Works fine
Does the browser go to the correct URL? All the code works with and without variables if I name the variable outerTagName
That is completely insane (as you’re probably aware). The error is likely being caused in code I cannot see.
Is there any mention of strUserName ANYWHERE else in your code base? (Hit Ctrl-H and search everywhere.)
What happens when you log the content of strUserName from inside the method to the console?