how to add condition to check if an element is present and if it is not present, another action should be done.
Who can help on that?
how to add condition to check if an element is present and if it is not present, another action should be done.
Who can help on that?
Have you try?
if WebUI.waitforElementPresent(to,timeout) {
//Do This}
else {
//Do That}
MaKatalon said:
Have you try?
if WebUI.waitforElementPresent(to,timeout) {
//Do This}
else {
//Do That}
here is my code:
if(WebUI.waitForElementPresent(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/Pending Work Itemsâ),0)){
WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/Pending Work Itemsâ))
}
else{
WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/a_Sign outâ))
}
it does not work
it does not do the sign out
Ziyaad said:
MaKatalon said:
Have you try?
if WebUI.waitforElementPresent(to,timeout) {
//Do This}
else {
//Do That}here is my code:
if(WebUI.waitForElementPresent(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/Pending Work Itemsâ),0)){
WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/Pending Work Itemsâ))
}
else{
WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/a_Sign outâ))
}
it does not work
it does not do the sign out
it work now, i just tested it and there was a timeout now the same code workâŚ
Thank you mate
Good to hear that.
MaKatalon said:
Good to hear that.
Yes, at first i have lots of pressure when i start using Katalon, but now, i have been granted enough time to explore the tool to the maximum.
However, i wanted to know is it possible to assign a for example for the line below, to put into a variable?:
Original:
WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/a_Sign outâ)
**If possible like this:
**def = WebUI.click(findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/a_Sign outâ)
Hope to hear from you soon?
Not sure what you intend to do, why do you need an action to be a variable ? WebUi.Click is an action .
Indeed WebUI.Click is an action and i made a mistake in my questionâŚHowever, i wanted to check if this one is feasible:
def X = findTestObject(âMemority_V1/Approve Internal Identity/Approve Internal Identity Home/a_Sign outâ)
and then perform an If condition with X.
Yes, findTestObject returns a TestObject as its return value when it found the test object. You can assign it to a TestObject variable.
But, take note that the return value that you going to assigned into the Variable is a TestObject, it is not a âconditionâ that you can directly utilized in your âif elseâ statement.
Here is my IF condition:
if (WebUI.verifyElementPresent(a, 10) || WebUI.verifyElementPresent(b, 10)) {
WebUI.click(findTestObject('Memority\_V1/Create Internal Identity/Create Internal Identity/button\_Cancel'))
} else {
WebUI.verifyElementPresent(findTestObject('Memority\_V1/Create Internal Identity/Create Internal Identity Home/input\_The task has been taken'))
WebUI.click(findTestObject('Memority\_V1/Create Internal Identity/Create Internal Identity Home/input\_The task has been taken'))
}
The problem is that it always failed when doing the IF and the IF in my current state should be false.
How can i solved this problem?
Hi Ziyaad,
showing the error you encounter would help to understand better on the problem.