Git Product home page Git Product logo

webdriveragent's Introduction

WebDriverAgent GitHub license Build Status Carthage compatible

WebDriverAgent is a WebDriver server implementation for iOS that can be used to remote control iOS devices. It allows you to launch & kill applications, tap & scroll views or confirm view presence on a screen. This makes it a perfect tool for application end-to-end testing or general purpose device automation. It works by linking XCTest.framework and calling Apple's API to execute commands directly on a device. WebDriverAgent is developed and used at Facebook for end-to-end testing and is successfully adopted by Appium.

Archiving

We are archiving WebDriverAgent. Thanks to the community who have used it! The code will remain here for your future use, but will no longer be actively supported by Facebook.

In May 2019, we open sourced IDB, “iOS Development Bridge”, a command line interface for automating iOS Simulators and Devices. We are currently migrating our own internal projects from WDA to IDB, and suggest checking it out as an alternative.

More information on IDB:

Overview

WebDriverAgent is a WebDriver server implementation for iOS that can be used to remote control iOS devices. It allows you to launch & kill applications, tap & scroll views or confirm view presence on a screen. This makes it a perfect tool for application end-to-end testing or general purpose device automation. It works by linking XCTest.framework and calling Apple's API to execute commands directly on a device. WebDriverAgent was developed and used at Facebook for end-to-end testing and is successfully adopted by Appium.

Features

  • Works with device & simulator
  • Implements most of WebDriver Spec
  • Implements part of Mobile JSON Wire Protocol Spec
  • USB support for devices
  • Inspector endpoint with friendly user interface to inspect current device state
  • Easy development cycle as it can be launched & debugged directly via Xcode
  • Unsupported yet, but works with tvOS & OSX

Demo Video

Getting Started

To get the project set up just run bootstrap script:

./Scripts/bootstrap.sh

It will:

  • fetch all dependencies with Carthage
  • build Inspector bundle using npm

After it is finished you can simply open WebDriverAgent.xcodeproj and start WebDriverAgentRunner test and start sending requests.

More about how to start WebDriverAgent here.

Known Issues

If you are having some issues please checkout wiki first.

For Contributors

If you want to help us out, you are more than welcome to. However please make sure you have followed the guidelines in CONTRIBUTING.

License

WebDriverAgent is BSD-licensed. We also provide an additional patent grant.

Have fun!

webdriveragent's People

Contributors

adamjernst avatar antiarchit avatar artemevvfb avatar bootstraponline avatar chendo avatar czwuwei avatar esnyder262 avatar fr0l avatar imurchie avatar jaredly avatar jonahss avatar kazucocoa avatar lawrencelomax avatar marciok avatar marekcirkos avatar matthewhorst avatar michel-slm avatar mmmulani avatar nghiadhd avatar nsfish avatar qmfrederik avatar rafe-g avatar sergey-plevako-badoo avatar srinivasantarget avatar ssynix avatar wfanforever avatar yaphatak avatar zats avatar ziczhu avatar zsol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webdriveragent's Issues

Tests fail on Real Devices

I run tests from the command line.
It's ok to run tests with simulators:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination platform=iOS Simulator,name=iPhone 6' test
But fails on real devices:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination platform=iOS,name=MyDeviceName' test
Here's part of xcodebuild's output:
2016-04-22 16:08:20.444 XCTRunner[363:71868] Running tests... 2016-04-22 16:08:20.467 XCTRunner[363:71868] The bundle “WebDriverAgentRunner” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. 2016-04-22 16:08:20.467 XCTRunner[363:71868] (dlopen_preflight(/var/containers/Bundle/Application/4E924101-F9BB-4C8C-833F-F19698954E86/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner): Library not loaded: @rpath/WebDriverAgentLib.framework/WebDriverAgentLib Referenced from: /var/containers/Bundle/Application/4E924101-F9BB-4C8C-833F-F19698954E86/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner Reason: image not found) ** TEST FAILED **

Unable to close app via XCUITests

Hi,

I'm trying to kill the app. I tried the following:
curl -X DELETE -H "Content-Type: application/json" -d "{"session":"29E17024-0123-4FA7-A019-22FE8248463E"}" http://10.0.0.71:8100

curl -X DELETE http://0.0.0.71:8100/session/29E17024-0123-4FA7-A019-22FE8248463E/

Neither of these work. Am I doing something wrong? Or am I misunderstanding what should be happening with this endpoint? Thank you!

WebDriver Tests on Real Devices?

I think I've fundamentally misunderstood something about what XCTWebDriverAgent is for. Is it possible to run a WebDriver test on a real device using XCTWebDriverAgent? I'm somewhat confused that an invocation of /session requires a bundle ID and an app, because I'm just expecting to launch Safari on the device before running a WebDriver test. If I do provide my own app, what exactly does XCTWebDriverAgent allow me to do with it that I can't already do with xcodebuild? The docs don't really say. Thanks for your help!

Is it possible to Run UIAWebDriverAgent on real device?

Is it even possible to run UIAWebDriverAgent on real device?

Hello guys, I've been playing with WebDriverAgent for a while. The one base on XCUITest works smooth on both simulators and real devices. But when I try to run the older one that build on top of AccessibilityUtilities.framework and UIAutomation.framework on real device, I ran into some problems.

The README inside UIAWebDriverAgent project dir seems to be the older version of the WebDriverAgent' README, which did't mention much about real device, which make sense since it's just a blank XCUITest.bundle.
So I'm not sure if this is possible to run UIAWebDriverAgent on real device. If it does, could you shed some light about how you guys manage to do it? I would be really appreciated :)

The problems I've encountered are descirbed below.

Problems

First off, the UIAWebDriverAgent project can't be linked because the 2 private frameworks mention above are missing.
I managed to find AccessibilityUtilities.framework at

~/Library/Developer/Xcode/iOS DeviceSupport/7.1.2 (11D257)/Symbols/System/Library/PrivateFrameworks/AccessibilityUtilities.framework
~/Library/Developer/Xcode/iOS DeviceSupport/8.3 (12F70)/Symbols/System/Library/PrivateFrameworks/AccessibilityUtilities.framework
~/Library/Developer/Xcode/iOS DeviceSupport/9.0.2 (13A452)/Symbols/System/Library/PrivateFrameworks/AccessibilityUtilities.framework
~/Library/Developer/Xcode/iOS DeviceSupport/9.3.1 (13E238)/Symbols/System/Library/PrivateFrameworks/AccessibilityUtilities.framework

The UIAutomation.framework is a bit tricky, I found it at

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/9.3\

By manually add two framework search path to the UIAWebDriverAgent project, the app was successfully loaded and ran on my devices, but it keep stuck in
UIAWebDriverAgent run failed
and the warning in console

2016-05-09 15:03:36.947 WebDriverAgent[7652:681225] UIAutomation is not enabled on this device. UIAutomation must be enabled in Settings.
2016-05-09 15:03:36.948 WebDriverAgent[7652:681225] *** Terminating app due to uncaught exception 'kUIAExceptionUIAutomationNotEnabled', reason: 'UIAutomation is not enabled on this device. UIAutomation must be enabled in Settings.'

I tried to turn the UIAutomation setting on, the same warning still shows.

Unable to launch app some applications on device

Xcode 7.3 beta, iPhone6, iOS 9.2
(Tried to do this on Xcode 7.2 stable, but ran into this issue).

Forgive me if I'm missing something fundamental, but here are the steps to repro:

Following the README, I start the server by running the UITestingUITests test.
I see the blue screen on the device and logs indicating that the server is ready.

Then I POST the following:

{
    "desiredCapabilities" : {
        "bundleId" : "my.bundle.id",
        "app" : "/Users/me/path/to/my/bundle.app"
    }
}

The app starts launching, but never gets past the launch screen. We get an error originating from [app launch] in + [FBSessionCommands routes] for POST /session:

<unknown>:0: error: -[UITestingUITests testRunner] : UI Testing Failure - Failure 
attempting to launch <XCUIApplicationImpl: 0x155d9b0e0 my.bundle.id at 
/Users/me/path/to/my/bundle.app>: Error Domain=XCTestIDEInterfaceErrorDomain Code=11 "Expired token: no operation still exists for this token." UserInfo={NSLocalizedDescription=Expired token: no operation still exists for this token.}

Reading through the XCUITest logs, it looks like it is trying to launch the app, but gets stuck on something. The following logs repeat dozens of times before the failure:

15:34:26.021 Xcode[23698:192220] Test process requested launch process status with token 140567250394480
15:34:26.021 Xcode[23698:192220] Got status 0 from operation for token 140567250394480
15:34:26.124 XCTStubApps[994:291909]    Got status 0
15:34:26.124 XCTStubApps[994:291659]    Throttling status checking for 0.197316s...
15:34:26.323 XCTStubApps[994:291659]    Checking status...

applicationAlertWithApplication queries application for XCUIElementTypeAlert and XCUIElementTypeSheet.

alert = application.sheets.element;

Not all XCUIElementTypeSheet are alerts. Therefore when checking if an alert is obstructing the view, if there is a popover sheet in the view that can be dismissed by clicking anywhere in the window, we cannot dismiss this sheet since we return a response saying "Alert is obstructing view".

Im suggesting removing line 200 in FBAlertViewCommands.m:

  • (XCUIElement *)applicationAlertWithApplication:(FBApplication *)application
    {
    XCUIElement *alert = application.alerts.element;
    if (!alert.exists) {
    alert = application.sheets.element;
    }
    return alert;
    }

    to ensure we only return this response if the element is a XCUIElementTypeAlert.

@marekcirkos I can fix real quick if you give me green light.

Crash when opening inspector

When I try to open the inspector, the app crashes with the following error:

2016-04-19 15:06:05.322 XCTRunner[34587:4130444] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001106e7d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000011015bdeb objc_exception_throw + 48
    2   CoreFoundation                      0x00000001106e7cbd +[NSException raise:format:] + 205
    3   Foundation                          0x000000010fd92ff7 -[NSBundle initWithURL:] + 87
    4   Foundation                          0x000000010fd930a6 +[NSBundle bundleWithURL:] + 45
    5   WebDriverAgentLib                   0x000000011db88fe2 __47+[FBInspectorCommands inspectorResourcesBundle]_block_invoke + 178
    6   libdispatch.dylib                   0x0000000112f953d7 _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x0000000112f82bab dispatch_once_f + 76
    8   WebDriverAgentLib                   0x000000011db88f08 +[FBInspectorCommands inspectorResourcesBundle] + 136
    9   WebDriverAgentLib                   0x000000011db89068 +[FBInspectorCommands inspectorHTMLFilePath] + 40
    10  WebDriverAgentLib                   0x000000011db88d58 __29+[FBInspectorCommands routes]_block_invoke + 88
[...]

Since it worked in the past for me, I tracked it down with git bisect and it was introduced with commit 760a571 (Replaced static library with framework so that it can be build with Carthage).

Have we support webview context?

{
  "value": "Unhandled endpoint: /session/5918AD27-DC17-4135-A311-00DE4B4BAE11/context -- http://localhost:8100/ with parameters {\n    wildcards =     (\n        \"session/5918AD27-DC17-4135-A311-00DE4B4BAE11/context\"\n    );\n}",
  "sessionId": "5918AD27-DC17-4135-A311-00DE4B4BAE11",
  "status": 1
}

By the way, according to the de-facto standard spec-draft, server should response with result status 501 not implemented, thanks team!

Throw error if an invalid locator selector is used

Seems like right now, a fineElement command will return no elements if you use an invalid locator selector. But it would be more useful if the server threw a {status: 32, value: "invalid locator requested: ${usingText}"
https://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes

I think throwing that error in a catchall else {} statements (here)[https://github.com/facebook/WebDriverAgent/blob/36326bd1fcea3229314db6d3c4412d4442993dcf/WebDriverAgentLib/WebDriverCommands/FBFindElementCommands.m#L155] would work. Whats the best way of throwing that particular error here?

Can we use this to run XCUITests for an app ?

Currently we have set of XCUITests written in Swift for our app and we execute them on simulator. If FBSimulatorControl can launch parallel simulators in the same machine, can we use XCTWebDriverAgent to run the tests in parallel in the simulators launched ? Is this doable and if yes how can one do it ? Any information on this would very helpful. Thanks!

Output message when server is ready to accept requests

I have a test which programmatically launches WebDriverAgent on a simulator and hits the /tree endpoint after the WebDriverAgent process outputs its first message (Built at XX:XX:XX). This test fails.

But if I wait for 3 seconds before issuing the http request, it passes.

I think we should output a message when the http server is ready. I suggest something similar to appium like:
WebDriverAgent REST http interface listener started on 0.0.0.0:8100

dyld fatal error

Running UITestingUITests, iPhone6, iOS 9.2, Xcode 7.2

"Stub Apps" appears to install but then immediately crashes with dyld_fatal_error :

dyld: could not load inserted library '/private/var/mobile/Containers/Data/Application/B8DD9504-DE4C-4418-8D5E-3B492DDCA07E/tmp/IDEBundleInjection.framework/IDEBundleInjection' because no suitable image found.  Did find:
    /private/var/mobile/Containers/Data/Application/B8DD9504-DE4C-4418-8D5E-3B492DDCA07E/tmp/IDEBundleInjection.framework/IDEBundleInjection: mmap() errno=1 validating first page of '/private/var/mobile/Containers/Data/Application/B8DD9504-DE4C-4418-8D5E-3B492DDCA07E/tmp/IDEBundleInjection.framework/IDEBundleInjection'

The same setup works with Xcode 7.3 Beta (the version released two days ago). By that I mean, the app will at least launch and the server will start / be able to receive commands.

Code coverage?

Is it possible to get code coverage data from WebDriverAgent runs?

Fix Test Target

It's currently failing to build when linking against UIAutomation.framework and the symbols for libraries added via Cocoapods like KissXML.

Coordinate-based clicking and touch events

Hey,

I was reading through your documentation, and I was wondering if this project supports clicking or gestures using X and Y coordinates. Is this accomplishable with WebDriverAgent or XCTest private header files?

If so, could you share with me instructions or ideas on how to do so?

Thanks!

Run XCUITest bundle from command line (without xcworkspace) ?

Is it possible to invoke the XCUITest bundle (TestRunner.app) for physical devices from the command line directly, i.e. without needing the xcodeproject/workspace?

E.g., could I email someone just the TestRunner.app bundle and have them be able to use the driver from the command line as though they had the full project?

I am aware of xctool and it seems like this might be able to do it, but it appears to only work for simulators.


Note, if I install the TestRunner bundle to device and launch it manually, the server will still respond to /status, but am unable to start a new /session. I assume the bundle needs to be run with some certain environment configuration or needs to be run in the context of something like testmanagerd.

How to automate app like whatsapp with WebDriverAgent?

I saw Simon gave a WebDriverAgent demo in Selenium Conference 2015. That is awesome. Can boot several simulators simultaneously and run the test case. We have a app like Whatsup. So we need to boot 2 simulators at least at the same time to test the chat scenario. So I checked the WebDriverAgent and FBSimulatorControl projects, but there are less info for them. So I have couple questions:

  1. I know can start agent in test runner. But how to find elements and manipulate? Do I need to involve Selenium? But how Selenium talks to WDA? Could you give me some hints?

2.You know I need to boot several simulators simultaneously. But how to boot in WDA? WDA need to call FBSimulatorControl,right? How WDA works with FBSimulatorControl?

There are too many questions, hoho. Thanks in advance from China.

Apple TV support

Unable to launch WebRiverAgent for Apple tv.
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=tvOS Simulator,name=Apple TV 1080p' test

Output:
xcodebuild: error: Unable to find a destination matching the provided destination specifier: { platform:tvOS Simulator, name:Apple TV 1080p } Available destinations for the "WebDriverAgentRunner" scheme: { platform:iOS Simulator, id:E72FA047-A6D3-4022-8ECE-B0A8D5E87239, OS:9.3, name:iPad 2 } { platform:iOS Simulator, id:382BF112-B13F-409D-9536-EB2057B89C68, OS:9.3, name:iPad Air } { platform:iOS Simulator, id:D90BE5FF-652F-436A-8183-2980BC869A90, OS:9.3, name:iPad Air 2 } { platform:iOS Simulator, id:06D34327-7C77-4E31-8D6C-E0EC1CCC0D82, OS:9.3, name:iPad Pro } { platform:iOS Simulator, id:382CEBEE-6988-48C5-A96E-0161B106F826, OS:9.3, name:iPad Retina } { platform:iOS Simulator, id:CD9716D3-BF32-4B15-85DF-E507989F3A84, OS:9.3, name:iPhone 4s } { platform:iOS Simulator, id:D729D43C-FD98-4AFC-9F28-F838EB13F376, OS:9.3, name:iPhone 4s } { platform:iOS Simulator, id:74EAAD21-F586-4320-9222-759CEA8131D4, OS:9.3, name:iPhone 5 } { platform:iOS Simulator, id:7DB6E165-D9CD-4648-9D46-0C0A32FA30B5, OS:9.3, name:iPhone 5 } { platform:iOS Simulator, id:DAE4A0AE-42E9-4BD3-8B70-CF6CFB44DA7C, OS:9.3, name:iPhone 5s } { platform:iOS Simulator, id:06543375-0828-4879-A5C5-18021099EAF9, OS:9.3, name:iPhone 6 } { platform:iOS Simulator, id:240F1E30-5C0D-4CBB-AA01-0B613732DF32, OS:9.3, name:iPhone 6 Plus } { platform:iOS Simulator, id:02EFA4DA-B5DA-4666-903E-45963D9A7FAE, OS:9.3, name:iPhone 6s } { platform:iOS Simulator, id:147BF49F-49BA-40B1-A5F3-87A478A32D61, OS:9.3, name:iPhone 6s } { platform:iOS Simulator, id:C608567B-57B8-4741-B631-D9F7A792EB32, OS:9.3, name:iPhone 6s Plus }

Does WebDriverAgent support Applet TV os?

typing requires the software keyboard <- provide a useful error

Trying to use a command like PUT /value or PUT /keys to type into a text field fails pretty cryptically with a "cannot tap ..." error if the software keyboard is not up.

Is there an easy way to detect if software keyboard is enabled/present in order to give users a more informative error?

Extended README

It would be good to have an extended README, which gives examples of how to use it.
At the moment it just describes how to start the driver.

Safari support broken on master branch

Safari launches then immediately terminates using Xcode 7.3 iOS 9.3 iPhone 6 Simulator.

$ xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'platform=iOS Simulator,name=iPhone 6' test
$ curl -X POST -H "Content-Type: application/json" -d "{"desiredCapabilities":{"bundleId":"com.apple.mobilesafari"}}" http://localhost:8100/session/

I see the same behavior when attempting to automate Safari via the Ruby bindings.

# gem install selenium-webdriver
require 'rubygems'
require 'selenium-webdriver'

caps = {"bundleId" => "com.apple.mobilesafari"}
server_url = 'http://localhost:8100/'

# Safari launches then closes
driver = Selenium::WebDriver.for :remote, desired_capabilities: caps, url: server_url

If I attempt to use the driver then an exception is raised:

> driver.navigate.to "http://google.com"
Selenium::WebDriver::Error::IndexOutOfBoundsError: Unhandled endpoint: /session/1D174704-DA9C-415D-B198-34562B1B8639/url -- http://localhost:8100/ with parameters {
    wildcards =     (
        "session/1D174704-DA9C-415D-B198-34562B1B8639/url"
    );
}
from /Users/bootstraponline/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok'

It'd be great to have a Safari example that demos loading a webpage with any of the existing selenium bindings.
#120

difficulty typing into UIATextField

Typing into a TextField on our test app, I'm running into difficulties.

Hitting the /value endpoint like POST http://localhost:8111/session/c3152b20-b9ea-4143-bb73-cbfa66ed80a0/element/3/value] with body: {"value":["hello"]} triggers this code:

https://github.com/facebook/WebDriverAgent/blob/79cc04d9fff39da03d49180986cca1fbb227ba33/WebDriverAgentLib/WebDriverCommands/FBElementCommands.m#L91-L100

We check if the element has keyboard focus. Logging the value of [element hasKeyboardFocus] evaluates to (null) even when the element has keyboard focus in the simulator.

If the keyboard is hidden, the keys cannot be tapped, so we call [element tap] to bring it up. My problem is that this code never brings the keyboard up.

If I hit the /click endpoint for the TextField the keyboard comes up, and I can then hit the /value endpoint and everything works. But the "automatic" tap to give the TextField focus and bring up the keyboard isn't working for me.

What baffles me, is the same method call is used in the /click and /value endpoints, so why one works and the other doesn't is beyond me. I tried adding a sleep command after the tap to no avail.

Have you been able to call the /value endpoint to type, without first calling /click?

Swift?

Any thoughts on rewriting the XCUITest branch in Swift?

Xcode 8 support

Project compiles however some integration tests are failing.

  • Tapping seems to be broken for accepting and dismissing alerts
  • Springboard tests are broken
  • 'fb_isVisible' is broken

Native apps on real devices

Hi guys,

Is it possible to launch native apps and inspect/automate them (e.g. the Settings app) on real devices with this - or just the simulator? Struggling with real device.

Documentation: No need for grep

You if you want to spawn on a booted device you can simply use the booted flag, e.g.
xcrun simctl spawn booted /Users/mehdi/src/WebDriverAgent/Build/...

No need for grep 😉

How to run IOS safari using selenium?

I've heard this library can be used to replace appium. But the documentation here is quite limited.
We have a bunch of unit tests that target a ruby/rails website (not an app). So we need to target IOS Safari. Anyways, the test suite uses selenium under the hood. Currently we use appium, but it's not very nice, being so undependable. We would like selenium to use this WebDriverAgent to communicate with a simulator or a real device instead.

Is that possible? And if so how?

Memory Leak

I write a Monkey test using WDA and come across with this memory issue.
The following statement will cause a memory leak:
all_elements = [FBFindElementCommands descendantsOfElement:app withClassName:@"XCUIElementTypeAny"]
If I do it in a for loop, XCTRunner will finally run out of memory and be killed by jetsam (iOS system protection when its memory is exhausted).

JSONWP session handling?

Hi @mmmulani, @shs96c et al! Thanks for this. I'm starting to play around with it a bit. Having trouble starting a session:

~/C/l/webdriveragent git:master ❯❯❯ curl -X POST http://localhost:8100/wd/hub/session -d '{"desiredCapabilities": {"app": "com.apple.mobilesafari"}}'
{
  "value" : "Unhandled endpoint: \/wd\/hub\/session -- http:\/\/localhost:8100\/ with arguments {\n    desiredCapabilities =     {\n        app = \"com.apple.mobilesafari\";\n    };\n}",
  "status" : 1
}%

I can get the details for an imaginary session that doesn't exist:

~/C/l/webdriveragent git:master ❯❯❯ curl http://localhost:8100/session/foo
{
  "value" : {
    "CFBundleVersion" : "50",
    "device" : "iphone",
    "CFBundleIdentifier" : "com.apple.springboard",
    "sdkVersion" : "8.4",
    "browserName" : "SpringBoard"
  },
  "status" : 0
}%

I can even delete this session:

~/C/l/webdriveragent git:master ❮❮❮ curl -X DELETE http://localhost:8100/session/foo
{
  "value" : "",
  "status" : 0
}%

I can, apparently, get buttons!

~/C/l/webdriveragent git:master ❯❯❯ curl -X POST http://localhost:8100/session/foo/element -d '{"using": "class name", "value": "UIAButton"}'
{
  "value" : {
    "ELEMENT" : 4,
    "type" : "UIAButton"
  },
  "status" : 0
}%

But I can neither click it nor retrieve its text.

Just wondering if I'm missing something or if these endpoints haven't been implemented yet.

Not able to Run in real device

I tried to install application in real device but I am getting below error :

ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/Developer/Library/PrivateFrameworks'
ld: framework not found UIAutomation
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Let me know If I am doing anything wrong.
Please help me to fix this issue.

WebDriverAgentRunner crashes when installed on real iOS 9.3.2 iPhone 6

After bootstrapping the project, I selected the WebDriverAgentRunner then selected Project -> Test. The app is installed on an iPhone 6 running 9.3.2, but crashes on launch. iOS console logs show the following:

Jul 2 19:51:49 iPhone6 SpringBoard[58] : Installed apps did change.
Added: {(
)}
Removed: {(
)}
Modified: {(
"com.apple.test.WebDriverAgentRunner-Runner"
)}
Jul 2 19:51:50 iPhone6 kernel[0] : AppleKeyStore:Sending lock change 0 for handle 0
Jul 2 19:51:50 iPhone6 UserEventAgent[26] : LockStateNotifier aksNotificationCallback posting notification: com.apple.mobile.keybagd.lock_status
Jul 2 19:51:50 iPhone6 UserEventAgent[26] : (Note ) PIH: Lock status changed.
Jul 2 19:51:50 iPhone6 MobileMail[388] : Ignoring lock state change from disabled to disabled
Jul 2 19:51:50 iPhone6 mobile_house_arrest[975] : vend_afc: Could not set SO_NOSIGPIPE: Bad file descriptor
Jul 2 19:51:50 iPhone6 com.apple.xpc.launchd1 : Service exited with abnormal code: 1
Jul 2 19:51:51 iPhone6 syncdefaultsd[968] : (Note ) marked "com.me.keyvalueservice" topic as "enabled" on <APSConnection: 0x126e2bbc0>
Jul 2 19:51:51 iPhone6 kernel[0] : AppleKeyStore:Sending lock change 0 for handle 0
Jul 2 19:51:51 iPhone6 UserEventAgent[26] : LockStateNotifier aksNotificationCallback posting notification: com.apple.mobile.keybagd.lock_status
Jul 2 19:51:51 iPhone6 UserEventAgent[26] : (Note ) PIH: Lock status changed.
Jul 2 19:51:51 iPhone6 MobileMail[388] : Ignoring lock state change from disabled to disabled
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
for arm64.
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : Connecting to com.apple.debugserver service...
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : Got a connection, waiting for process information for launching or attaching.
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : Sending AppProxy info: sequence no: 156, GUID: 993A9B8E-650B-4F55-A075-7A03E2FE49A9.
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : error: Unrecognized event type: . Ignoring.
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : About to launch process for bundle ID: com.apple.test.WebDriverAgentRunner-Runner
Jul 2 19:51:52 iPhone6 SpringBoard[58] : SecTrustEvaluate [leaf IssuerCommonName SubjectCommonName]
Jul 2 19:51:52 iPhone6 com.apple.xpc.launchd1 : The DisableASLR key is no longer respected. Please remove it.
Jul 2 19:51:52 iPhone6 securityd[93] : secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Jul 2 19:51:52 iPhone6 amfid[225] : SecTrustEvaluate [leaf IssuerCommonName SubjectCommonName]
Jul 2 19:51:52 iPhone6 kernel[0] : xpcproxy[979] Container: /private/var/mobile/Containers/Data/Application/90839F27-B3FE-4BF3-AF75-EE9755B330A1 (sandbox)
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : In completion handler, got pid for bundle id, pid: 979.
Jul 2 19:51:52 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : Got a connection, launched process /private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app (pid = 979).
Jul 2 19:51:52 iPhone6 SpringBoard[58] : LICreateIconForImage passed NULL CGImageRef image
Jul 2 19:51:53 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : 1 +0.000000 sec [03d2/0c07]: error: ::mach_vm_region_recurse ( task = 0x1a13, address => 0x636a626f62696c2f, size => 0, nesting_depth => 1024, info => 0x16fd02ccc, infoCnt => 12) addr = 0x636a626f62696c2f err = (os/kern) invalid address (0x00000001)
Jul 2 19:51:53 iPhone6 com.apple.xpc.launchd[1] : assertion failed: 13F69: launchd + 116796 [9F6284CF-8A17-36CC-9DB5-85D510A21F14]: 0x3
Jul 2 19:51:53 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : 2 +0.069258 sec [03d2/0c07]: error: ::mach_vm_region_recurse ( task = 0x1a13, address => 0xf098de5b00e2a45a, size => 0, nesting_depth => 1024, info => 0x16fd02ccc, infoCnt => 12) addr = 0xf098de5b00e2a45a err = (os/kern) invalid address (0x00000001)
Jul 2 19:51:54 iPhone6 XCTRunner[979] : Running tests...
Jul 2 19:51:54 iPhone6 securityd[93] : secTaskDiagnoseEntitlements MISSING keychain entitlements: no stored taskRef found
Jul 2 19:51:54 iPhone6 amfid[225] : SecTrustEvaluate [leaf IssuerCommonName SubjectCommonName]
Jul 2 19:51:54 iPhone6 kernel[0] : AMFI: XCTRunner(pid 979) - [deny-mmap] mapped file does not the same team identifier as main process: /private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/Frameworks/KissXML.framework/KissXML
Jul 2 19:51:54 iPhone6 kernel[0] : AMFI: XCTRunner(pid 979) - [deny-mmap] process has team identifier K3C3J3YZRH: /private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/Frameworks/KissXML.framework/KissXML
Jul 2 19:51:54 iPhone6 kernel[0] : AMFI: XCTRunner(pid 979) - [deny-mmap] mapped file has team identifier 8C96M9YR8S: /private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/Frameworks/KissXML.framework/KissXML
Jul 2 19:51:54 iPhone6 XCTRunner[979] : The bundle “WebDriverAgentRunner” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
Jul 2 19:51:54 iPhone6 XCTRunner[979] : (dlopen_preflight(/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/WebDriverAgentRunner): Library not loaded: @rpath/KissXML.framework/KissXML
Referenced from: /private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/WebDriverAgentLib
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/Frameworks/KissXML.framework/KissXML: mmap() errno=1 validating first page of '/private/var/containers/Bundle/Application/6A4098C5-4538-4F67-A7C2-9688D369A880/WebDriverAgentRunner-Runner.app/PlugIns/WebDriverAgentRunner.xctest/Frameworks/WebDriverAgentLib.framework/Frameworks/KissXML.framework/KissXML')
Jul 2 19:51:54 iPhone6 SpringBoard[58] : BSXPCMessage received error for message: Connection invalid
Jul 2 19:51:54 iPhone6 SpringBoard[58] : HW kbd: Failed to set (null) as keyboard focus
Jul 2 19:51:54 iPhone6 com.apple.xpc.launchd1 : Service exited with abnormal code: 82
Jul 2 19:51:54 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : 3 +0.235305 sec [03d2/1b0b]: error: ::read ( -1, 0x16e246a38, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Jul 2 19:51:54 iPhone6 com.apple.debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-340.3.124
[978] : Exiting.
Jul 2 19:51:54 iPhone6 testmanagerd[974] : testmanagerd exiting, idle with no test activity.
Jul 2 19:51:54 iPhone6 SpringBoard[58] : Application 'UIKitApplication:com.apple.test.WebDriverAgentRunner-Runner[0xa7f3]' exited voluntarily.

Running the exact same project targeting a simulator works fine. Are there additional steps to getting this working on a real device that I'm missing?

Include snapshot.identifier in tree output & inspector

WebDriverAgent sets name to wdName in FBDebugCommands.m which makes it impossible to tell if an accessibility identifier has been used. The accessibility label is set to name when there's no accessibility identifier. Labels aren't great to use for automation because they'll change depending on the locale. It'd be great if WebDriverAgent supported info[@"identifier"] = ValueOrNull(snapshot.identifier); as an independent attribute.

Webview/Safari testing?

I can have the appium driver connect to the Safari debugger, like we do currently with our Instruments solution.

Does Facebook currently have a different method for testing webviews/safari using XCUITest?

@mmmulani

Run XCUITest bundle via WebDriverAgent

Many companies are investing in using XCUITest directly because that's Apple's official recommendation for UI Testing. It'd be great to have an endpoint in WebDriverAgent that accepts a zip of XCUITests and returns a base64 encoded zip file with the contents of the run.

On Android, running Instrumentation tests from the command line is easy with spoon. I haven't found an equivalent way to easily run XCUITests without someone manually using XCode. Would xctool enable people to run XCUITests programmatically?

Amazon supports this via uploading a zipped XCTest bundle. It's not clear how they run the bundle once it's uploaded.

Adding XCUITest bundle support would enable all existing automation providers that offer appium to execute XCUITests. That'd be a big win for customers who currently don't have many options when selecting device clouds with XCUITest support.

/cc @jlipps @Jonahss

Document 'double-debug' in Xcode 7

One of the awesome things about WDA is that allows you to connect the Debugger to the running WebDriverAgent in the lldb command line/Xcode rather than some massive UIAutomation.js scaffolding. Documenting how to do this in the README and the Radar for the double-debug issue under Xcode 6.

Dependencies are not built with Carthage

Hello FB team.

Currently I've trouble building WebDriverAgent's dependencies with Carthage: KissXML, RoutingHTTPServer, peertalk
it looks like dependencies do not have schemes to build with Carthage... (i might be wrong)

here is a build log:

carthage bootstrap --platform ios
*** No Cartfile.resolved found, updating dependencies
*** Fetching WebDriverAgent
*** Fetching KissXML
*** Fetching peertalk
*** Fetching RoutingHTTPServer
*** Checking out KissXML at "5.0.3"
*** Checking out RoutingHTTPServer at "v1.0.0"
*** Checking out peertalk at "5a0495a7b7d81b68e25ea1933c755b677cb040da"
*** Checking out WebDriverAgent at "348209dcde6d638876218f35c9a57b71ef4ad013"
*** xcodebuild output can be found in /var/folders/0d/119bm57x58l6c_6ddx46d__00000gn/T/carthage-xcodebuild.5HyiMf.log
*** Skipped building KissXML due to the error:
Dependency "KissXML" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/robbiehanson/KissXML/issues/new
*** Skipped building RoutingHTTPServer due to the error:
Dependency "RoutingHTTPServer" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/mattstevens/RoutingHTTPServer/issues/new
*** Skipped building peertalk due to the error:
Dependency "peertalk" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/rsms/peertalk/issues/new
*** Skipped building WebDriverAgent due to the error:
Dependency "WebDriverAgent" has no shared framework schemes for any of the platforms: iOS

If you believe this to be an error, please file an issue with the maintainers at https://github.com/facebook/WebDriverAgent/issues/new

Build doesn't work

I cloned this project to my mac and followed the build instructions exactly. Right after opening xcode I immediately built, and got two build errors (Plus a build warning which I fixed).

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: - dynamic not specified the following flags are invalid: -ObjC error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lxml2 error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lxml2 is not an object file (not allowed in a library)

Support xcode 7.3

We met error like this:

/WebDriverAgent/XCTWebDriverAgentLib/Commands/FBCustomCommands.m:41:43: error: implicit conversion increases floating-point precision: 'float' to 'CGFloat' (aka 'double') [-Werror,-Wdouble-promotion]
  CGFloat duration = (requestedDuration ? requestedDuration.floatValue : 3.f);
          ~~~~~~~~                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now we fixed this error, but could not get any elements instead due to some reason I can not understand.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.