Russ Thomas said:
Jacqueline,
I was wondering if I can put everything in 1 script and depending on
which browser I run the test, the script can be executed successfully.
There’s nothing wrong with that, IMO.
That said, I would probably place the decision (the if/else) in a custom Keyword and call that from my test case. That way, the test case will look clean (well, “cleaner”, anyway).
Plus, doing that, you don’t need to choose a profile based on a decision that one test case might need - let the test (or Keyword) decide. The less profiles you create, the better, IMO.
Hi Russ,
I’ve tried to put it this way but it has an error on the custom keyword method upon running the script.
@Keyword
public void setBrowser(String browser) {
if (browser.equalsIgnoreCase(‘Firefox’)) {
WebUI.uploadFile(findTestObject(‘Object 1’), ‘C:\\Desktop\\ABC.txt’)
Thread.sleep(1000)
Runtime.getRuntime().exec(‘C:\\Desktop\\AutoIt\\UploadDataFile.exe’)
}
else (browser.equalsIgnoreCase('Chrome')) {
WebUI.uploadFile(findTestObject('Object 1'), 'C:\\\Desktop\\\ABC.txt')
WebUI.sendKeys(findTestObject('Object 2'), Keys.chord(Keys.TAB, Keys.ENTER))
Thread.sleep(1000)
Runtime.getRuntime().exec('C:\\\Desktop\\\AutoIt\\\UploadDataFile.exe')
}
}
In the script, I put like this:
CustomKeywords.‘test.HeaderLine.setBrowser’(‘Object 1’)
Error message:
09-03-2018 03:43:45 PM - [ERROR] - groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (test.HeaderLine$_setBrowser_closure1) values: [test.HeaderLine$_setBrowser_closure1@76304b46]
Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), and(java.lang.Boolean), any(groovy.lang.Closure)
09-03-2018 03:43:45 PM - [END] - End action : test.HeaderLine.setBrowser
09-03-2018 03:43:45 PM - [END] - End Test Case : Test Cases/Create Preference
09-03-2018 03:43:45 PM - [ERROR] - Test Cases/Create Preference FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: java.lang.Boolean.call() is applicable for argument types: (test.HeaderLine$_setBrowser_closure1) values: [test.HeaderLine$_setBrowser_closure1@76304b46]
Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), and(java.lang.Boolean), any(groovy.lang.Closure)