appium with no reset does not close the simulator after execution - selenium-webdriver

I have to run some test suite on two remote machines.
So, after one suite, i reset the app and for the next suite, app starts well.
But the problem is, after completing the total execution
driver.quit()
just close the app but it does not close the simulator as
no reset is true.
So, is there a way to close the xcode simulator using appium or selenium?
I do not want to use ssh and full reset option.
I also do not want to use
killall "Simulator" as it needs ssh connection.

try this
String closesim[] = {"killall","iOS Simulator"};
Runtime.getRuntime().exec(closesim);

You can try directly close simulator by passing below code in you AfterClass,Or AfterSuit method . which close all the simulator which is open in system.
For my case its working i am not sure in your cases its work because if you pass below command in terminal you can find its close your simulator.
runtime.exec("xcrun simctl shutdown all");

Related

Protractor application get paused when system sleeps

I am working in a large project. There are about minimum 160 specs to be executed with protractor, and it consumes more than one hour to finish automation testing. But issue is my system get sleeps in between it when no action is performed. Is there any way to make system alive until protractor finishes its execution.
So that I could run it without system sleep. I cant increase my sleep time because it had to be run in many sytem. Please let me know how could I handle it ?
I am using chrome for running the automation.
Cheers.
Would it be possible to let me know what OS you are using? So that I can give step by step information. For example: if you are using windows machine then
Goto --> Control Panel\Hardware and Sound\Power Options --> Change the Sleep settings make it to "Never"
It will remain open for your lifetime till you switchoff your computer.
By the way there is no relation this question to Protractor.

Selenium get last browser window

Every time I run my test selenium opens another Firefox window. It's annoying to see so many windows after several runs of the test. Is it possible to utilize the previous opened one?
For Selenium 2 (WebDriver), try creating a new object for FF:
ffWebDriver = new FirefoxDriver();
This should create an object of the Firefox web-driver that you can control and won't be quit until you call:
ffWebDriver.Quit();
This is something NOT possible. Please look into https://code.google.com/p/selenium/issues/detail?id=18 to have an idea why is it so. If only multiple windows opened is a problem here, you can quit all the browser instances opened after each test by calling driver.quit(); method.
In case you are using Python bindings, you might want to have a look into this : http://webdriverplus.org/en/latest/browsers.html#reuse-browser

Codename one crashes on device only

I have a codenameone app that works fine in the desktop emulator (windows 7) but when I run it on my Xperia Z1 (android) it crashes when I try to show a new form (this has been working fine).
I am currently using the free account and so do not get crash reports (e.g. a call stack). And it'll take me forever to keep trial-and-error hoping to find it ....
Any suggestions?
Install the Android SDK, connect your device with a cable and launch the DDMS tool to connect to the device. You should be able to see the log messages and stack trace thru that and it might give you a better indication of what is going on.

Selenium Grid: Error communicating with the remote browser. It may have died

I have two machines, one with all the stuff I need (Eclipse + TestNG +scripts) and the other one with just browsers installed.
I use Selenium Grid 2.35.0.
Everything seems to be fine except the problem that very often I get this error:
Error communicating with the remote browser. It may have died.
Scripts are not complicated at all, I run them one-by-one, so it just happens randomly. I don't think it's because of the browser.
Any idea/fix?
If you need more info I'm here.
The only time I get that error is when I manually close the browser myself. I would verify that the machine withe the browsers is stable.
It could also be due to calling driver.quit() and not instantiating another driver (I haven't ever done this, so I don't know what error this throws)
I notice this error as well but ONLY when using Selenium grid (using 2.35 but 2.38 exists now)
When I run locally I don't get error communicating with the browse but typically it can happen when there is a bug with your setup and teardown code (maybe one of your classes creates an instance of your browser before your setup function gets called)
See How to close child browser window in Selenium WebDriver using Java
ensure to call driver.close(); on every popup / new windows / new tab you open during the test (after switching to it using driver.switchTo())
and to call driver.quit(); at the end of the session (generally in #AfterClass annotated method)

Start Play Application and Close Window

I have a play application on a Windows 7 machine which I want to start via double click on a batch file.
This batch file starts a service. Calls the play application to run in production mode, waits for 5 seconds and open a browser with a specified url.
Therefore I used the following script:
call net start service1
CALL "D:\play-1.2.5\play.bat" start --%%%%prod -Dprecompiled=true
TIMEOUT /T 4
call "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" localhost:9000
exit
Now when I start the batch file the window opens and all commands are executed. Sadly Play is still writing his output to cmd and the window is not disappearing. If I close the window manually play is stop executing.
If I run play with "play start" from cmd, play is starting in the background and everything is fine. Play still runs even if I close the window.
I want to have exactly this behaviour when I start the application with my batch file.
Thanks
If you were using a linux-like environment, I' d recommend you to use 'nohup' command and a '&' sign in the end. However, as far as I know there is no direct equivalent of beautiful 'nohup' command on Windows, unfortunately. So, what I can think of is, you can create a tiny win api application that utilizes CreateProcess command and give it the required parameter to hide command line window as soon as the process is created. There are also other process creation functions such as WinExec that you can use to hide command line.
I don't know what Play is so I can only take a guess :) but try using the batch without the call's as I don't think they are necessary, and you never know, might fix the issue.
1) You see Play's output because ot redirect only system.out but write system.err to the same console.
2) I also have this problem and looking for a solution. As a workaround you could try to use some Java Wrapper and install your Play! application as a Windows Service.
3) Play! app could be started via Ant task. I haven't tried this yet.

Resources