"driver.quit()" in teardown() does not work

1,917 views
Skip to first unread message

shuai sun

unread,
Jul 8, 2013, 12:04:36 PM7/8/13
to appium-...@googlegroups.com
Hi all,
       I modified the python sample-code to run my own test. The test part went well, but when it finishes, driver would never quit.
It just paused in "driver.quit()" in teardown().
       Any one has a similar issue?
       Thanks in advance!


       Shuai

Jonathan Lipps

unread,
Jul 8, 2013, 1:27:28 PM7/8/13
to shuai sun, appium-...@googlegroups.com
What do appium logs say?

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

shuai sun

unread,
Jul 8, 2013, 1:48:45 PM7/8/13
to appium-...@googlegroups.com, shuai sun
Following is appium log:

...
...
debug: Appium request initiated at /wd/hub/session/5ce6cb73-8c1e-4866-aa5d-ab25628d5556
info: Shutting down appium session...
info: [INST] 2013-07-08 17:05:08 +0000 Debug: (null).dragInsideWithOptions({endOffset:{x:"0.1", y:"0.1"}, touchCount:"2", duration:"1.5", startOffset:{x:"0.1", y:"0.99"}})
       2013-07-08 17:05:15 +0000 Stopped: Script was stopped by the user
Instruments Trace Complete (Duration : 22.345934s; Output : /source/.../instrumentscli0.trace)

info: [INSTSERVER] Instruments exited with code 0
info: Deleting plists for bundle: com.mycompany.mypruduct.mytarget
info: [INSTSERVER] Socket closed forcibly due to exit
info: [INSTSERVER] Instruments socket server closed
info: Deleted tracedir we heard about from instruments (/source/.../instrumentscli0.trace)


It would pause in here.

Jonathan Lipps

unread,
Jul 8, 2013, 1:50:57 PM7/8/13
to shuai sun, appium-...@googlegroups.com
Can you make a gist to the full log please?

shuai sun

unread,
Jul 8, 2013, 1:57:16 PM7/8/13
to appium-...@googlegroups.com, shuai sun

shuai sun

unread,
Jul 8, 2013, 2:00:04 PM7/8/13
to appium-...@googlegroups.com, shuai sun
On the client side I used Java, and source code is: https://gist.github.com/shuaisun/5950974
Following is the log:

Jul 8, 2013 1:07:21 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: I/O exception (org.apache.http.NoHttpResponseException) caught when processing request: The target server failed to respond
Jul 8, 2013 1:07:21 PM org.apache.http.impl.client.DefaultRequestDirector tryExecute
INFO: Retrying request

Jonathan Lipps

unread,
Jul 8, 2013, 2:10:18 PM7/8/13
to shuai sun, appium-...@googlegroups.com
That all looks fine on the appium side. Not sure why it's hanging on the client side. Any Java experts have a clue?

shuai sun

unread,
Jul 8, 2013, 2:17:51 PM7/8/13
to Jonathan Lipps, appium-...@googlegroups.com
This might not Java specific. I also used a python script, but it hanged in there also.
Seems driver.quit() didn't get response from the server, and it just hanged in there until timeout.

Following is my python script:

import unittest
import os
from random import randint
from selenium import webdriver
import time


class TestSequenceFunctions(unittest.TestCase):

    def setUp(self):
        # set up appium
        #app = os.path.abspath(app)
        self.driver = webdriver.Remote(
            command_executor='http://10.1.44.116:4723/wd/hub',
            desired_capabilities={
                'browserName': 'iOS',
                'platform': 'Mac',
                'version': '6.1',
            })
        self._values = []

    def test_ui_computation(self):
print "Now start the test:"

element_list = self.driver.find_elements_by_tag_name("UIAWindow")
for element in element_list:
print element.id, element.tag_name, element.size, element.text
self.driver.execute_script("mobile: swipe",{"touchCount":"2.0","startX":"0.1","startY":"0.99","endX":"0.1","endY":"0.1","duration":"1.5","element":element_list[0].id})
time.sleep(1)
self.driver.find_element_by_name("Simple Bar Graph").click()
time.sleep(1)
element_list = self.driver.find_elements_by_tag_name("UIAPicker")
for element in element_list:
print element.id, element.tag_name, element.size, element.text


    def tearDown(self):
print "Now tear down the driver, and quit:"
try:
self.driver.quit()
except Exception,e:
print e


if __name__ == '__main__':
    unittest.main()
--
Best Regards,
         
                Shuai Sun

Umass Boston
55 Edwin St, Quincy, 02171
USA
Cellphone: 617-515-5588

bootstrap online

unread,
Jul 8, 2013, 2:24:47 PM7/8/13
to shuai sun, Jonathan Lipps, appium-...@googlegroups.com
Can you reproduce with any of the sample apps? It may be specific to your app.

shuai sun

unread,
Jul 8, 2013, 2:45:44 PM7/8/13
to bootstrap online, Jonathan Lipps, appium-...@googlegroups.com
Hi Joanthan and Matt,
     Thank you for your suggestions. I just tried running node sample-code on the mac, and reproduced the same issue.
     Could it be caused by system version or related issue? I just upgrade my OSX from 10.7 to 10.8. Before doing that, I was able
to run the test scripts, but it also take a fairly long time to close the driver. (After simulator behaviors finishing, it takes about
40-60 seconds to close the test).
      Would that provide some information?
     Thank you

bootstrap online

unread,
Jul 8, 2013, 2:47:53 PM7/8/13
to shuai sun, Jonathan Lipps, appium-...@googlegroups.com
My guess is there's some issue with your system. driver.quit works for
me and it's fast.

shuai sun

unread,
Jul 12, 2013, 10:42:57 AM7/12/13
to appium-...@googlegroups.com, shuai sun, Jonathan Lipps
Hi all,
     These days I am trying to read source code, but could not figure out which part is wrong.
And I just paste server&client screen, in case if any of you find something.


This is the client log, and it just paused at "Delete" line:

   Driving the web on session: a40af064-0264-49c2-8fb3-a1802de1bd66
 > POST: /session/:sessionID/elements { using: 'tag name', value: 'textField' }
 > POST: /session/:sessionID/element/0/value { value: [ '2' ] }
 > POST: /session/:sessionID/element/1/value { value: [ '3' ] }
 > POST: /session/:sessionID/elements { using: 'tag name', value: 'button' }
 > POST: /session/:sessionID/element/2/click 
 > POST: /session/:sessionID/elements { using: 'tag name', value: 'staticText' }
 > GET: /session/:sessionID/element/6/text 
 > DELETE: /session/:sessionID 


Following is server log, also paused at "delete" line:


info: Responding to client with success: {"status":0,"value":"5","sessionId":"a40af064-0264-49c2-8fb3-a1802de1bd66"}
GET /wd/hub/session/a40af064-0264-49c2-8fb3-a1802de1bd66/element/6/text 200 124ms - 88
debug: Appium request initiated at /wd/hub/session/a40af064-0264-49c2-8fb3-a1802de1bd66
info: Shutting down appium session...
info: [INST] 2013-07-12 14:33:41 +0000 Stopped: Script was stopped by the user
       Instruments Trace Complete (Duration : 8.920796s; Output : /Users/qa/instrumentscli1.trace)

info: [INSTSERVER] Instruments exited with code 0
info: Deleting plists for bundle: D.TestApp
info: [INSTSERVER] Socket closed forcibly due to exit
info: [INSTSERVER] Instruments socket server closed
info: Deleted tracedir we heard about from instruments (/Users/qa/instrumentscli1.trace)


Thank you

Jonathan Lipps

unread,
Jul 12, 2013, 11:10:42 AM7/12/13
to shuai sun, appium-...@googlegroups.com
Can you paste a link to the entire log output please

shuai sun

unread,
Jul 12, 2013, 2:46:46 PM7/12/13
to Jonathan Lipps, appium-...@googlegroups.com
Hi all,
       Thank you for your reply. This is the server log:

      Recently, I upgraded to 10.8, and installed xcode5 beta. But I had some issue running the script using xcode5, so I just roll back to xcode4.

      I dived into source code and found issue happened when appium tried to close session:
      appium received "DELETE: /session/:sessionID"
      appium shutdown instruments.
      Then issue happens.
      It wouldn't call "me.onDeviceDie(code, cb);", therefore would not call "getResponseHandler()"

      I have been stuck in here for a while. Any suggestion would be appreciated..
      Thank you!



Appium.prototype.stop = function(cb) {
  if (this.sessionId === null || this.device === null) {
    logger.info("Trying to stop appium but there's no session, doing nothing");
    return cb();
  }

  var me = this;

  logger.info('Shutting down appium session...');
  this.device.stop(function(code) { 
  //I inserted a log sentence in here, it was NOT executed.
    me.onDeviceDie(code, cb);
  });
};

IOS.prototype.stop = function(cb) {
  if (this.remote) {
    this.stopRemote();
  }
  if (this.instruments === null) {
    logger.info("Trying to stop instruments but it already exited");
    // we're already stopped
    cb();
  } else {
    var me = this;
    if (cb) {
      this.onStop = cb;
    }

    this.instruments.shutdown();
    me.queue = [];
    me.progress = 0;
  }
//I inserted a log sentence in here, it was executed.
};





Jonathan Lipps

unread,
Jul 12, 2013, 3:02:11 PM7/12/13
to shuai sun, appium-...@googlegroups.com
  //I inserted a log sentence in here, it was NOT executed.

I think it would execute if you restart the appium server. The log shows that it must have been executed (see the "Clearing out appium devices" line)

shuai sun

unread,
Jul 12, 2013, 3:50:48 PM7/12/13
to Jonathan Lipps, appium-...@googlegroups.com
Hi Jonathan,
     Thank you for pointing this. I found the issue was not that it couldn't be executed, but taking too long.
     Finally, I got the script(example/node/simplest.js) finish.
"info: Responding to client with success: {"status":0,"value":null,"sessionId":"5450dd62-c7e9-44ac-a147-fb22953019a5"}
DELETE /wd/hub/session/5450dd62-c7e9-44ac-a147-fb22953019a5 200 421267ms - 89"
     
     Before updating to 10.8, it took about 100seconds, but now longer.
     And following is the updated log:

     My machine is Mac Mini with cpu i5 2.3g, 4g ram ddr3, and osx 10.8

     
     Thank you,

    
     
     

    

Jonathan Lipps

unread,
Jul 12, 2013, 5:11:36 PM7/12/13
to shuai sun, appium-...@googlegroups.com
That's really strange! I wonder why there would be such a long delay.

shuai sun

unread,
Jul 12, 2013, 7:06:50 PM7/12/13
to Jonathan Lipps, appium-...@googlegroups.com
Hi Jonathan,
          I tried several times. As I mentioned in early reply, but it's "paused" instead of "not executed".
          Any suggestions for this situation?
         Thank you,


Appium.prototype.stop = function(cb) {
  if (this.sessionId === null || this.device === null) {
    logger.info("Trying to stop appium but there's no session, doing nothing");
    return cb();
  }

  var me = this;

  logger.info('Shutting down appium session...');
  this.device.stop(function(code) { 
  //I inserted a log sentence in here, it was Paused.
    me.onDeviceDie(code, cb);
  });
};

IOS.prototype.stop = function(cb) {
  if (this.remote) {
    this.stopRemote();
  }
  if (this.instruments === null) {
    logger.info("Trying to stop instruments but it already exited");
    // we're already stopped
    cb();
  } else {
    var me = this;
    if (cb) {
      this.onStop = cb;
    }

    this.instruments.shutdown();
    me.queue = [];
    me.progress = 0;
  }
//I inserted a log sentence in here, it was executed.
};

Jonathan Lipps

unread,
Jul 12, 2013, 7:09:23 PM7/12/13
to shuai sun, appium-...@googlegroups.com
I would add a log statement after if (this.remote) here, before and after this.stopRemote(). Maybe stopRemote() is causing the pause? Otherwise this is all just simple javascript function calling and shouldn't take any real time.

shuai sun

unread,
Jul 31, 2013, 3:18:31 PM7/31/13
to appium-...@googlegroups.com
Hi Everyone,
          Here I am to update. This issue was simply because the app I am testing is huge. "Huge" I mean 4G for each stages. When I load 2 stages into simulator, total over 8G, tear down phase became very long. 
         When I reset the simulator and test a smaller app, it became quick again. 
       
         So each time, I only load one stage, and the tear down phase is less than 100 seconds, which is acceptable.

        Thanks for helping
Reply all
Reply to author
Forward
0 new messages