Opening and Closing Browser - tosca

I am new to TOSCA (just trying to learn by self-studying - have a trial license).
I was trying to build a simple test case to open and close an application. In it I have used the TBox Window Operation Module to close the Browser but when I run it in scratchbox, I don't get any output. It just opens the browser to the demo app and exits without giving a success or an error message. I want to know why it isn't closing the browser window and giving me a success message.
Here is a screenshot:
Any help on this is appreciated.

Your testcase looks alright to me. I just tried myself and this should work.
After you've run the test you can always open up the scratchbook again, by clicking the 'scratchbook' button in the ribbon on the 'home' tab in the 'go to' group:
You should then see the details of your last run. A very common thing that happens to me is that Tosca cannot uniquely identify the window (e.g. because I have two windows with the same title open). The error would look like this:
So I'd check if opened the demo webshop more than once.
What is also good to know is, that Tosca will use your standard browser in the 'OpenUrl' module if you have not specified it otherwise, and the 'Window Operation Module' is agnostic to that. You can explicitly specify which browser to use in the 'OpenUrl' module by providing a TestConfiguration Parameter like this:
Hope that helps.

just use CloseBrowser module which can be found under Standard Modules.
Standard Modules are the set of modules which are shipped by default along with the installation of any Tosca instance.

You can use "close browser" standard module instead of window operation module to close the browser window.

Related

Google Optimize: Unable to preview experience. Please make sure to enable cookies and restart the browser

I can't preview my Google Optimize experience. Google optimize throws below error:
This happens to me quite often too. The suggestion Google gives is wrong. Clearing cookies and restarting the browser does not fix it. Sometimes rebooting does, but that's a huge disruption.
What I found to work pretty reliably is to end the preview (dropdown), then click the EDIT button to go to the editor. Come back to the setup page, then try Debug again. Debugger should work again.
This is how it worked for me:
In Chrome go to Clear Browsing Data (chrome://settings/clearBrowserData).
Make sure you select checkboxes Cookies and Cached images and files.
Submit the form by hitting the button "Clear data".
Go to preview experience.
For me it started working when I gave the Google Optimize plugin access to all pages (not just the page running the experience).
I think I've found a fix for this. Go to the top right corner of chrome (the three dots) Settings > Privacy & Security > Cookies & other data > and add the url in the bottom section called "sites that can always use cookies"
Example
There can be multiple reasons.
Most obvious: enabled cookies like mentioned by others. should help
If it does not work even when cookies are enabled and you have restarted the browser then more chances are that the issue is in the Experience/Test that you are trying to preview. This can be due to:
A preview is already running in another tab. Turn off preview
2.You have set the experience to run on certain URL patterns and you are trying to preview on a page that does not qualify the criteria.
You have set some Audience rules which are not being met fully. For example: You have set the Audience Device type to mobile and you are trying to preview on a Desktop. Although Optimize will load the preview in a mobile mode but it will not be able to run the experience properly.
In my case the issue was due to wrong device type. I hope it helps.
It's also possible to get this "Unable to preview experience. Please make sure to enable cookies and restart the browser" error message if the content you're trying to modify doesn't exist when Optimize tries to modify it.
I had Optimize set to modify on page load, but the page I was working with was a form, where the text I wanted to modify didn't exist until I clicked through to the second step of the form (still on the same URL).
I was able to just run the study instead on another similar page that had all the text loaded at the start. I'd guess that setting Optimize to trigger from a custom event triggered upon loading the second step of the form instead of "on page load" would also have resolved the issue.
If you are using chrome then:
Click the context menu in the browser toolbar to the right of the
address bar.
Choose Settings.
Select/Search the "Security and Privacy" section.
Choose "Cookies and Other Site Data" Ensure that "Allow all cookies" is selected.

Click on Save button on File Download popup in IE11 in robot framework

Is there a way to click on the Save or Open button in the pop up that appears while downloading a file in IE 11? I am using Robot Framework AutoIt Library.
I can handle the windows that comes subsequent after clicking the Save or Save As option.
What kind of file are you downloading? Depending on the file type you should be able to set a default behaviour in IE11.
Personally I think AutoIT solutions with this are overkill, I'd recommend looking at the following blog post for alternative ideas if possible:
https://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/
However, if this is a scenario you simply MUST automate as you're doing then my first line should help you.

Is there a way in unix to programmatically force a terminal window to "front"

We have a script that always runs in a terminal window. Sometimes users will do stuff in other windows and our script terminal gets moved behind all these other windows, and they forget to bring it back to the front. Is there a way to force it so it is always on top or front? Sort of like how annoying popup windows work? We are on solaris 8
There is a way indeed! Check out a tool called xdotool. It does exactly what you need and more.
Here is the link to the download: http://www.semicomplete.com/projects/xdotool/#idp20144
and here is the link to the documentation: http://www.semicomplete.com/projects/xdotool/xdotool.xhtml
I suggest you look into the Window commands, especially: windowactivate
I can give you the exact command if you like to save time? Or you can browse through the documentation. Hope this helps!

Open a URL in a certain browser tab/window

From within my Qt application, I would like to open URLs repeatedly in the same browser tab/window. (Kind of "refreshing" this tab programmatically)
Using
QDesktopServices::openUrl(QUrl("http://www.domain.tld"));
opens a new tab/window for every call. Is there a possibility to add a "target=" parameter somewhere?
What you are asking for is impossible to do in the way you imagine it. openUrl() uses the operating system to specify the program to open the argument as mentioned in its documentation.
There might be some workarounds, but none of them will work well, or work on all browsers. It's just that this kind of fine-grained control is likely to be impossible for you.
If you want control of a tab in a browser, you could find the window represented by that tab and close it right before opening the new one. This solution is kind of hacky.
Another hacky solution is to find the HWND of the edit box holding the URL, and to try changing its text using SendMessage(). This won't work on Chrome, however, as it does not use a separate control for the URL window. It might work on Firefox or IE.
The better solution is to make your own web browser you control using the Qt WebKit. It is pretty easy to render a page in it and change the url viewed. The QWebView is an easy to use implementation of the QtWebKit.
Maybe you will found this usefull:
You can open the webpage and the reload the active tab.
If you supply the name of the browser as an argument, it'll find and reload the current page
https://unix.stackexchange.com/questions/37258/refresh-reload-active-browser-tab-from-command-line

Coded UI Testing in IE - How to upload a file?

With our CUIT tests in Visual Studio we have the problem that we cannot record the Browser Button action in IE. We just get:
C:\fakepath\Document1.txt
But this obviously does not lead to the real document in a playback. And it's not possible to just type the path into the Browse text field anymore.
Just FYI: This applies to the Coded UI Testing Framework in Visual Studio 2010 Feature Pack 2. The recorder only works with IE.
Any ideas?
Not being able to access the file upload control is supposed to be a security feature. I guess you need to step out of your environment and into the windows environment to accomplish anything.
If you use a macro recorder that can playback from command line (like http://www.jitbit.com/macro-recorder/versionhistory/) or a similar means, you may be able to record the missing step here (like a simple tab key hit - provided you have focused on the control before the upload control -, a typed text, and another tab key hit) and start the resulting "batch". Or you can even record a mouse click.
However, if this test runs in other browsers (if I understand you correctly), wouldn't it be safe enough to assume that it runs in IE as well, because after all you are using a standard control?
Actually, turns out I can edit the value "C:\fakepath\Document1.txt" manually in the uitest UIMaps file and change it to a real path. And it works in the reply like this.

Resources