0

My below present simple batch file, on double clicking triggers the simple execution of my maven testng selenium webdriver script with NO issues

cd C:\Users\xxxxxxx\Documents\SelTestsWorkspace\QATesting
mvn -e clean test postman:send-mail

But, if i schedule this same batch file on windows task scheduler. Test Execution does manages to get triggered (after long struggle) but instead of firefox browser window, headless driver gets triggered (Without any change in code or properties or in any configurations). enter image description here

My simple doubt is, How is this POSSIBLE ?

1
  • Did you get this solved to make visible the browser for the below query you asked.I am looking for a solution for this. If so please share with me too.. Thanks in Advance. Hey, i was able to use jenkins and overcome my problem. An Interesting thing that happened with jenkins as well is that if Jenkins is started as part of Windows service, browser was again not visible for me on the desktop but starting jenkins directly from war file made the browser visible. Can anything of that sort is also getting happened here as well ?
    – semeena
    Commented Apr 25, 2018 at 6:18

2 Answers 2

1

As Niels noted, it might not actually be using a headless driver, it's probably just not running under your main desktop environment.

This will happen when using Task Scheduler if you don't have the correct Security options on the General tab of your task properties. They should look something like this:

enter image description here

If you set those options differently you won't be running the task using the current desktop environment, so even if you change the service user as Niels suggested, it still might run in a separate environment.

But it should still run fine. Does it not?

1
  • Thanks Mark for replying with fine details. It's a sanity script which needs to scheduled for daily execution on that specific machine and as it's a remote machine, I've chosen the options while setting-up the task which in any case atleast trigger the execution. Also, you both are correct in sense that execution is actually getting triggered but not my user desktop env. and since script is getting failed at irrelevant step. Hence kind of need the browser to be present on desktop. Have done some changes, will update with the details soon ! Commented Mar 11, 2017 at 13:31
1

Are you sure it is headless? The task scheduler is run as the "Local System account" by default on windows. Look under "Services" and the tasks schedulers properties.

Running programs under the Local System Account means it is not shown on your users desktop. It has its own environment. Also wonder if this is something you want todo.

You can run the scheduled tasks under the logged in user: https://serverfault.com/questions/777710/how-do-i-create-a-scheduled-task-that-will-run-as-the-logged-in-user

Better is to schedule tests with a build-server like Jenkins.

3
  • Thanks Niels for input. Yes, it's headles ... i could have added a screenshot of task manager where firefox & cmd process are present and i'm getting logs in surefire-report folder BUT nothing present on desktop. Probably i missed this thing to add, cmd.exe is also getting triggered in invisible form (i might sound drunk, but trust me :D). I understnad what you meant but i don't this type of interaction and i'm not sure i can edit that property. About the suggestion, eventually Yes, we have to move out Jenkins only but as of now ...this is the situation which needs to be handled Commented Mar 11, 2017 at 13:17
  • No, headless means without an UI. Your firefox is running under a different account with a UI. Just like a terminal server where more than one person is working on one machine. Schedule the task as a different user if you want to see the test running. You do need to be logged in and cant be in the login screen. Commented Mar 11, 2017 at 16:20
  • Hey, i was able to use jenkins and overcome my problem. An Interesting thing that happened with jenkins as well is that if Jenkins is started as part of Windows service, browser was again not visible for me on the desktop but starting jenkins directly from war file made the browser visible. Can anything of that sort is also getting happened here as well ? Commented Mar 13, 2017 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.