manishPatwari / WebDriverAgent

A WebDriver server for iOS that runs inside the Simulator.
Other
52 stars 15 forks source link

[Ref] iOS support #1

Open manishPatwari opened 6 years ago

manishPatwari commented 6 years ago

Original Issue : https://github.com/openstf/stf/issues/64

Comment : https://github.com/openstf/stf/issues/64#issuecomment-357255612

TuHuynhVan commented 6 years ago

@manishPatwari Thank you so much for you rocket response. I was able to see the socket connected for real device. Hence, I could see it in the connected device list.

However, I got another issue that after clicking on the connect device, it was disconnected and below was the log thrown:

Test Case '-[UITestingUITests testSocketRunner]' started.
    t =     0.00s Start Test at 2018-01-15 15:37:54.293
    t =     0.00s Set Up
2018-01-15 15:37:54.297 WebDriverAgentRunner-Runner[1113:314976] Built at Jan 15 2018 13:32:58
2018-01-15 15:37:54.389 WebDriverAgentRunner-Runner[1113:314976] socket connected
    t =    10.81s Find the Application "local.pid.58" 0x148258130
2018-01-15 15:38:05.144 WebDriverAgentRunner-Runner[1113:314976] Enqueue Failure: Application local.pid.58 is not running /Users/myname/myFolder/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 46 1
    t =    10.86s Find the Application "local.pid.58" 0x148258130
2018-01-15 15:38:05.151 WebDriverAgentRunner-Runner[1113:314976] Enqueue Failure: Application local.pid.58 is not running /Users/myname/myFolder/WebDriverAgent/WebDriverAgentRunner/UITestingUITests.m 46 1
2018-01-15 15:38:05.155 WebDriverAgentRunner-Runner[1113:314976] socket Connected to Client
2018-01-15 15:38:05.155 WebDriverAgentRunner-Runner[1113:314987] *** Assertion failure in -[XCUIScreen _screenshotDataForQuality:rect:error:], /Library/Caches/com.apple.xbs/Sources/XCTest_iOS/XCTest-13764/Sources/UITesting/XCUIScreen.m:230
2018-01-15 15:38:05.155 WebDriverAgentRunner-Runner[1113:314987] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'To screenshot a frame, it must have non-0 area.'
manishPatwari commented 6 years ago

@TuHuynhVan Please give the device information which you have used. We have tried this in real device and didn't face this issue. Device information will help us to debug it further.

TuHuynhVan commented 6 years ago

@manishPatwari I deployed on an iPhone 6S with below info:

        productVersion:             9.3.5
        buildVersion:               13G36
        deviceSoftwareVersion:      9.3.5 (13G36)
shubhankaryash commented 6 years ago

@TuHuynhVan Thanks for the info! We will test on lower OS versions and try to debug this issue.

TuHuynhVan commented 6 years ago

Thanks @shubhankaryash I also tried on another my iPhone, with version 10.3.2. The socket could not connect...

shubhankaryash commented 6 years ago

@TuHuynhVan I tried this on iPhone 7 with 10.2.1. I was able to connect to the socket. Do make sure that your system and mobile are connected to the same network, have no proxy and the localhost has been replaced with the ip. As far as the crash is concerned, I will try to get an iOS 9 device and give an update.

TuHuynhVan commented 6 years ago

@shubhankaryash as your guess, the second iPhone (version 10.3.2) was not on same network with the node server. I changed it to the same and I was able to connect and interact with it.

The version 9.3.5 is still crashed...

Anyway, thank you and the team so much! Even the interaction from Web UI is still slow (3s) but this is a significant movement!

Pls let me know what should I do for the version 9.3.5

shubhankaryash commented 6 years ago

@TuHuynhVan Glad we could resolve the iOS 10 issue. Rendering the screenshot from the device involves a lot of data being sent over the network. Hence it is still a bit slow even after the considerable optimisations we have done. We are still looking at solutions to compress this data and try to make this quicker.

I will inform you once I am able to get an iOS 9 device and test on it.

TuHuynhVan commented 6 years ago

@shubhankaryash Just wanna update, I just tried on another iPhone, version 11.1.2 is also OK! <3

TuHuynhVan commented 6 years ago

@shubhankaryash Can I just build the WDA on the target device then when I plug it into the host, I could see it connected from connected device list in stead of xcode test.... and keep the session in terminal?

And can I still run automation test (which requires WDA involved) on same target device? I think I just need to use another port for WDA instead of 8000. Am I right?

Thank you so much!

shubhankaryash commented 6 years ago

@TuHuynhVan You always need to run the tests through XcodeIDE/XcodeBuild. Having it installed beforehand and running it wont work. As far as running multiple tests on a single device is concerned, I am not sure but I think you can check by running them through the terminal.

I tested it out on iPadMini 9.3.5 and like you said it crashed. We are getting the screenSize with 0 dimensions from the API FBApplication has provided.

TuHuynhVan commented 6 years ago

@shubhankaryash Thank you for your confirmation. Let me: [1] build the WDA on the target iPhone [2] start xcode test... from terminal (viewing screen/interaction from Web UI purpose) [3] Start testing with Appium

To make sure that we can use the device for both purpose.

rdhandapani88 commented 6 years ago

@Team, Greetings and congrats for successfully achieving this. I tried this to install on real device IOS Version 11.0.1. and able to install WD and able to build the project. But i could not see the device in the browser. It says no device. When i check the console i see the below error,

WebDriverAgentRunner-Runner[2838:17916155] Task <09BB3D98-698A-42E9-9576-E4683841A2A3>.<1> finished with error - code: -1001

Task <09BB3D98-698A-42E9-9576-E4683841A2A3>.<1> HTTP load failed (error code: -999 [1:89])

Seems like i could not connect to Socket. My phone and Mac is in same network. I tried multiple ways by turn the proxy off etc., but no luck. Requesting your support here.

I can see the Simulator without any issues. I have issues in real device only. Please help. Also mention what IOS versions are supported.

rdhandapani88 commented 6 years ago

Webdriver Agent log.txt

Attaching the log for reference.

rdhandapani88 commented 6 years ago

Hi,

I resolved the previous issue, It is my bad that i have not giving the device ip . Now i can connect more devices parallel. But can you help how to inspect element in that. Two column, Tree of elements and Inspector are displayed blank. What to do to inspect element. Advance Thanks.

manishPatwari commented 6 years ago

@rdhandapani88 : Currently we have disabled inspect element because of performance issue. We will have a button and when its needed it can be enabled. But currently inspect is not available.

Catrinacen commented 6 years ago

@manishPatwari Great thanks for the excellent work from you and your team! When I test with iOS 11 iphones, below error messages keep showing up, do you have any clues?

2018-01-31 14:32:31.060223+0800 WebDriverAgentRunner-Runner[313:14745] TIC TCP Conn Failed [12:0x1cc17ea80]: 1:50 Err(50) 2018-01-31 14:32:31.064512+0800 WebDriverAgentRunner-Runner[313:14745] Task <3D64002F-9D54-4BC3-9DAE-EEE6A6D97662>.<1> HTTP load failed (error code: -1009 [1:50]) 2018-01-31 14:32:31.064899+0800 WebDriverAgentRunner-Runner[313:14744] Task <3D64002F-9D54-4BC3-9DAE-EEE6A6D97662>.<1> finished with error - code: -1009

These error message show up in Xcode IDE over and over again, and the 8000 webpage keeps "No Device connected".

More Details:

  1. tested trouble devices: iphone 8 plus & ios 11.2.2, iphone X & ios 11.0.1, iphone SE & ios 11.0.3
  2. devices and node server are in the same network, with no proxy
  3. "localhost" in FBWebSocket.m has been replaced with node server ip
  4. test can be successfully run with iphone 7 & ios 10.3.2

The error message with ios 11 iphones has bothered me for quite a long time, will really appreciate it if you guys have any ideas:)

shubhankaryash commented 6 years ago

@Catrinacen This should not be an OS specific issue because we have been able to run the tests successfully on iOS 11. I will try to get my hands on iPhone 8 Plus/ iPhoneX and give an update on it.

Catrinacen commented 6 years ago

@shubhankaryash Thanks for your response:) After further investigation, I doubt my issue is caused by the same reason as this common issue. Since my failure tests are all reproduced with the licensed machines in China which can support TD-LTE models, and the error messages shown in Xcode IDE seem to be related with network connection. This common issue is finally solved by "iproxy 8100 8100" method, is there any similar solution for our case? any possibility that your WDA client can connect with the node server through USB instead of wifi?

shubhankaryash commented 6 years ago

@Catrinacen Sorry for the late response but I have no context about the issue with the licensed machines in China. Unfortunately I won't really be of much help in this. However in case you do find a solution, I request you to post the same here as it would be helpful to other folks facing the same problem in the future.

Catrinacen commented 6 years ago

@shubhankaryash Thanks for your kind response:) Fortunately I found the solution in recent days, below are the details: ISSUE: the network connection issue is only reproduced on licensed iOS11 devices in China; SOLUTION: when I connect the issue devices to MAC, I share the MAC network through "iPhone USB / iPad USB" to the devices, finally the device clients can connect to the MAC ip (websocket server) successfully.

Hope that could be helpful.

shubhankaryash commented 6 years ago

@Catrinacen Thanks!

sus0bhanpanja commented 6 years ago

Hi ,

I have tried with few devices but i used to get disconnected very soon. Anyone else is facing the same issue or get any workaround for the disconnection issue. I tried in iPhone and iPad with large memory it works for 5-10 minutes low memory devices got disconnected even early. Any suggestion is highly appreciated.

Thanks, Susobhan

manishPatwari commented 6 years ago

@sus0bhanpanja Yes, this issue is already reported. You can check @shubhankaryash finding here. https://github.com/manishPatwari/WebDriverAgent/issues/4

ngbrito commented 5 years ago

Hello guys,

Im just getting started with stf... As I can see, you are able to use some ios devices ... is there a guide that I could follow to set my environment with android and ios?

tx

guadaran commented 5 years ago

Hello guys,

Im just getting started with stf... As I can see, you are able to use some ios devices ... is there a guide that I could follow to set my environment with android and ios?

tx

Hi @ngbrito

This project is independent from STF and is not integrated into it. If you want to use iOS devices you can try the guide in the README.

Regards.

ngbrito commented 5 years ago

Hello @guadaran ,

I tried to set it on my machine but at the very first command, I get this error

./Scripts/bootstrap.sh: line 46: pod: command not found

Do you have any ideia what Im missing?

guadaran commented 5 years ago

Hello @guadaran ,

I tried to set it on my machine but at the very first command, I get this error

./Scripts/bootstrap.sh: line 46: pod: command not found

Do you have any ideia what Im missing?

You need to install https://cocoapods.org on your machine

ngbrito commented 5 years ago

Hello guys,

Im getting this error:

"linker command failed with exit code 1 (use -v to see invocation)"

And I can't fix it. Can anyone help?

ngbrito commented 5 years ago

Hello guys,

Im getting this error when I try to start the server:

$sh ./Scripts/start-server.sh Starting Server Server started : http://10.77.149.145:8000 events.js:183 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::8000 at Object._errnoException (util.js:1022:11) at _exceptionWithHostPort (util.js:1044:20) at Server.setupListenHandle [as _listen2] (net.js:1367:14) at listenInCluster (net.js:1408:12) at Server.listen (net.js:1492:7) at Object. (/Users/bnatali/Documents/git/WebDriverAgent/Inspector/server.js:164:8) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12)

Can u help?

ngbrito commented 5 years ago

Hello guys,

I could build the project and start the server however, when I run this line in terminal:

xcodebuild test -workspace WebDriverAgent.xcworkspace -scheme WebDriverAgentRunner -destination "platform=iOS,id=801b7fd33897cea92f2b2dcb608eb19f260e6b66"

I get the following error: IDETestOperationsObserverErrorDomain Code=6

I already restarted device and computer. Still getting this error

Also, when I go to xcode and test WebDriverRunner then execute the above line, I get no error but the device does not appear in the browser?

By the way, when I try with a simulator, it works just fine.

Please guys, can you help?