How to handle if not finding on objects is not an error
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to handle if not finding on objects is not an error
I have a teststep for saving a file. On windows you know how to save as works. It can directly save or a pop-up window asks you do you want to overwrite with same name. Briefly, a file can be directly saved or it can overwrite. Both option is applicable for me.
So i don't want to take en error when save as window is appeared on the screen. Below code takes error like "Cannot obtain the window with the windowclass...." How can i fix the problem? Thank you
var saveAsWindow= Saveasobject
if (saveAsWindow.Exists)
{object.clickbutton();
Log.Message("overwritten button is selected.")
}
else
Log.message("overwritten window is not appeared. Because it is a new file.")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
My coworker and I tried to apply your suggestion but we still get errors when there is no window and errors when false (saveaswindow).
Screenshot is below;
Should we have done it differently? Do you have a solution suggestion?
Thank you.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
"saveaswindow" object is found if the Save As popup appeared. If object not found it will not do anyting actually and will just keep going test case.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So you taking error before your "if statment" take pleace and in my opinion it is working as it should.
FindEx needs to be done, on an object thats exists - for example whole screen like I did.
var page = Sys.Browser().Page('*')
@cagan Change saveAsWindow declaration. It can be some parent object that you have assurance of it's existence and try again 🙂
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for your guidance. I just want to notify that saveAsWindow can be found or not. Both case are not wrong for us. It will just do different things on both case.
So, if same file name exists then Save As popup appear on the screen, otherwise the file directly be saved. In this condition, we couldn't keep that taking parent object what will be used for Save As popup.

- « Previous
-
- 1
- 2
- Next »
- « Previous
-
- 1
- 2
- Next »