How can I capture a screenshot with AutoIt executed remotely via PsExec? - screenshot

I have to run an AutoIt script which does some actions and takes screenshots (using _ScreenCapture_Capture()) of these actions.
If I run the AutoIt script on my Windows machine the screenshots are taken perfectly.
The problem I have now is that I have to start the AutoIt script remotely using PsExec. The actions are executed fine, it is just that the screenshots are captured as black rectangles.
I assume that the problem is that PsExec will run my script in the non-interactive session 0 and not on the user's desktop. Is there a way to solve this problem and get appropriate screenshots?

_ScreenCapture_Capture needs the window you want to capture to be visible and active. Try WinActivate(...).

Related

How to make your selenium script unbreakable?

I am writing a selenium script using Java to automate a website workflow. I want to run this script 24/7 and make sure that it's always running without any crashes. I want to make it unbreakable.
Now let's say that the script has been running fine for some hours and suddenly chrome crashes so how do I make my script launch the chrome and start the execution from the start? Do I need to use any framework? I am learning TestNG.

Specify screen resolution for coded UI tests

I am running coded UI tests using Selenium from a build in VSTS.
The test library is built on a test agent (hosted and private available) and copied to a VM running Windows 10. Then the test agent is deployed to the VM and the task 'Run Functional Tests' is executed. The tests to be executed are selected through an association in the test manager of VSTS.
I would like to run these UI tests (in Chrome) in different screen resolutions, but when the test agent is executed, the headless session always runs in the default resolution of 1024x768. I need to run tests up to a 4k resolution. If there is a current session with the same credentials in a higher resolution, this session is "hijacked" and the tests run in the desired resolution.
But I cannot guarantee an existing session when those builds are triggers by either a schedule or another event.
I already followed an MSDN article how to specify a default resolution in the registry, but that doesn't work on neither Win10 nor on Srv2012.
Is there a parameter/setting in a test/run setting file that specifies the resolution of this headless session?
To avoid confusion: I know how to set the windows size of the browser, but that is limited to the maximum screen resolution, so the Selenium-specific commands to resize the browser don't do the trick ;)
Any hint appreciated! Thanks!

Selenium leaves control after clicking to file explorer Browse button in MS Edge

Selenium leaves control after clicking to file explorer Browse button in MS Edge. This works fine in Chrome and Firefox but absolutely blocking to run next step in the code. I tried code via all possible ways and below code works to click to Browse button but after this step selenium leaves control because file explorer window opens. Is this Selenium or MS Edge driver issue?
Steps:
1. Open ajax web application through MS Edge (works)
2. Click to browse button through web driver core or java script method (works)
3. Selenium gone, leaves control till we close file explorer button (doesn't work) - this works fine in GC and FF.
4 (Blocked). Send key to type file name or implement AutoIt script (works)
5 (Blocked). Click to open button via AutoIt script (works)
6 (Blocked). File attached fine (works)
Working code:
driver.findElement(By.id("browseID")).click();
AND
WebElement we = null;
((JavascriptExecutor)ClientSessionFactory.session().webDriver()).executeScript("document.getElementsByName('browseName')[0].click()", we);
Environment:
Selenium version - Latest 3.6.0
Browser - MS Edge
MS Edge Driver - Latest Release 15063
Application type - Ajax web
This is actually blocking attachment functionality and it would be great if selenium will fix this. So far i just see Autoit is the solution as a 3rd party software but it is very tedious to add separate scripts for every browse buttons in the application, any code by selenium blocks due to OS dialog appearance.
I encountered the same problem. One solution can be to manipulate the "browse" window using an Auto-It script (for example). Right before click on the "browse" button, execute the Auto-It script and set a "sleep" command in the beginning to wait for 1-2 seconds. Now you can click on "browse" button. Works fine for me.
Same issue. To fix it i pimped the AutoIt script using WinWaitActive() as a first directive to wait til window is active.
I run the script in a parallel process (subprocess.Popen in python) just before opening the file upload

How to disable firefox from opening while running test suite in Selenium IDE?

I am writing test scripts in Selenium IDE for my application but everytime when I run the test suite it opens up browser and performs all the actions and logs failures, if any. My requirement is to invoke the test script from command prompt using .bat file and generate a test report. I am able to do the same but the problem is firefox opens up and executes the test case one by one. Can anyone please suggest me how to disable Firefox window from opening up? Or is it just not possible to do so? Or do I need to switch to Selenium Webdriver in order to achieve my requirement? My application contains Ajax upto a lot of extent.
I have read many commands used in Selenium IDE but I could not find any command which can serve this purpose. Please suggest!
If you know any programming language supported by selenium-webdriver (Ruby, Java, Python, C#) then you should try PhantomJS WebDriver which allow to run scripts without opening visual browser session
Selenium-IDE are mean to invoke browser, that's how the script react to all the exact browser behavior.
Only selenium Webdriver allow you to run your browser under "Headless" mode, which in fact, put Firefox under X-virtual frame buffer in background, as above #Andersson suggested.
Unfortunately, there is no easy way to convert your Selenium-IDE script to your desire programming language at the moment.
If your concern is about "cluttered screen" in OS such as ubuntu, then your solution will be export the whole Selenium-IDE and firefox under another virtual X-display.

selenium script has to run continuously in server with out using eclipse

is it possible to run selenium script in server without using eclipse or command prompt.for every fixed time intervals my selenium script has to run automatically in backend with out any browser opening
This can be split into two questions;
Can I schedule a Selenium test?
Yes, there are many options including using a CI tool such as Jenkins, Hudson, Team City,etc. Alternatively you could write a shell script to run the command line, and schedule this to run every x hours.
Can I run Selenium without opening a browser?
Yes. As mentioned before you could go headless, but depending on complexity of your application and test, you may find headless is not suitable. However, you can use RemoteWebdriver to launch a browser on a different machine but the test would still be run on your back end, it would just be the browse launched remotely. See https://code.google.com/p/selenium/wiki/Grid2 and https://code.google.com/p/selenium/wiki/RemoteWebDriverServer