Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get 'xml' source reported while trying to get PageSource for iOS13 #13595

Closed
lubshilk opened this issue Nov 13, 2019 · 31 comments
Closed
Labels
Needs Info typically non-actionable; needs author to respond ThirdParty upstream problems XCUITest regarding xcuitest driver

Comments

@lubshilk
Copy link

The problem

The problem is not reported on IOS12, only on IOS13 for the same page
The Appium doesn't find and existing element on the page. When trying to catch page source of the page, getting the exception "Cannot get 'xml' source"

I've seen facebookarchive/WebDriverAgent#1001 for older Appium version but there is no solution for the problem

Environment

  • Appium version (or git revision) that exhibits the issue: 1.15.0 and 1.15.1
  • Last Appium version that did not exhibit the issue (if applicable): 1.14.2
  • Desktop OS/version used to run Appium: macOS Mojave
  • Node.js version (unless using Appium.app|exe): 10.16.3
  • Mobile platform/version under test: IOS 13.2.2
  • Real device
  • Xcode 11.2
@mykola-mokhnach
Copy link
Collaborator

There's nothing to do here unless we can get server and system logs

@mykola-mokhnach mykola-mokhnach added the Needs Info typically non-actionable; needs author to respond label Nov 13, 2019
@lubshilk
Copy link
Author

Will provide shortly, sorry

@lubshilk
Copy link
Author

@mykola-mokhnach
Copy link
Collaborator

What is the output of page source if you call mobile: source endpoint with format equal to json or description?

@lubshilk
Copy link
Author

Page source in description format: https://gist.github.com/lubshilk/cad8821c276bf59c33ae23499fa88bf5

@mykola-mokhnach
Copy link
Collaborator

how about json ?

@lubshilk
Copy link
Author

On json it was a problem reported and driver crashed:

2019-11-13 11:41:46:259 [HTTP] --> POST /wd/hub/session/2e01ee76-e448-41ec-a9f4-4f43654a5eeb/execute/sync
2019-11-13 11:41:46:259 [HTTP] {"script":"mobile: source","args":[{"format":"json"}]}
2019-11-13 11:41:46:260 [W3C (2e01ee76)] Calling AppiumDriver.execute() with args: ["mobile: source",[{"format":"json"}],"2e01ee76-e448-41ec-a9f4-4f43654a5eeb"]
2019-11-13 11:41:46:260 [XCUITest] Executing command 'execute'
2019-11-13 11:41:46:262 [WD Proxy] Matched '/source?format=json' to command name 'getPageSource'
2019-11-13 11:41:46:263 [WD Proxy] Proxying [GET /source?format=json] to [GET http://localhost:8100/session/21511BD0-0BE5-4120-A095-4E82E17702CF/source?format=json] with no body
2019-11-13 11:41:46:305 [Xcode]     t =    23.49s Find the Application 'com.cellact.secnum2'
2019-11-13 11:41:46:306 [Xcode] 
2019-11-13 11:41:46:306 [Xcode]     t =    23.50s     Requesting snapshot of accessibility hierarchy for app with pid 280
2019-11-13 11:41:46:306 [Xcode] 
2019-11-13 11:41:46:376 [Xcode] 2019-11-13 11:41:46.376642+0200 WebDriverAgentRunner-Runner[276:4676] Cannot take the snapshot of Application 'com.cellact.secnum2' after 15 seconds
2019-11-13 11:41:46:376 [Xcode] 2019-11-13 11:41:46.376778+0200 WebDriverAgentRunner-Runner[276:4676] Internal error: Error Domain=com.apple.dt.xctest.automation-support.error Code=5 "Timed out snapshotting com.apple.testmanagerd, app is either unresponsive or taking too long to snapshot." UserInfo={accessibility-error=-25204, NSLocalizedDescription=Timed out snapshotting com.apple.testmanagerd, app is either unresponsive or taking too long to snapshot.}
2019-11-13 11:41:46:377 [Xcode]     t =    23.57s Requesting snapshot of accessibility hierarchy for app with pid 280
2019-11-13 11:41:46:377 [Xcode] 
2019-11-13 11:41:46:384 [WD Proxy] Got response with status 200: {
2019-11-13 11:41:46:384 [WD Proxy]   "value" : {
2019-11-13 11:41:46:385 [WD Proxy]     "rawIdentifier" : null,
2019-11-13 11:41:46:385 [WD Proxy]     "isVisible" : "0",
2019-11-13 11:41:46:385 [WD Proxy]     "frame" : "{{0, 0}, {0, 0}}",
2019-11-13 11:41:46:385 [WD Proxy]     "value" : null,
2019-11-13 11:41:46:386 [WD Proxy]     "label" : null,
2019-11-13 11:41:46:386 [WD Proxy]     "type" : "Any",
2019-11-13 11:41:46:386 [WD Proxy]     "name" : null,
2019-11-13 11:41:46:386 [WD Proxy]     "isEnabled" : "0"
2019-11-13 11:41:46:387 [WD Proxy]   },
2019-11-13 11:41:46:387 [WD Proxy]   "sessionId" : "21511BD0-0BE5-4120-A095-4E82E17702CF"
2019-11-13 11:41:46:387 [WD Proxy] }
2019-11-13 11:41:46:389 [W3C (2e01ee76)] Responding to client with driver.execute() result: {"rawIdentifier":null,"isVisible":"0","frame":"{{0, 0}, {0, 0}}","value":null,"label":null,"type":"Any","name":null,"isEnabled":"0"}
2019-11-13 11:41:46:390 [HTTP] <-- POST /wd/hub/session/2e01ee76-e448-41ec-a9f4-4f43654a5eeb/execute/sync 200 131 ms - 142

@mykola-mokhnach
Copy link
Collaborator

2019-11-13 11:41:46:376 [Xcode] 2019-11-13 11:41:46.376778+0200 WebDriverAgentRunner-Runner[276:4676] Internal error: Error Domain=com.apple.dt.xctest.automation-support.error Code=5 "Timed out snapshotting com.apple.testmanagerd, app is either unresponsive or taking too long to snapshot." UserInfo={accessibility-error=-25204, NSLocalizedDescription=Timed out snapshotting com.apple.testmanagerd, app is either unresponsive or taking too long to snapshot.}

This XCTest error and I don't think we can do much about it. There is a possibility to increase the snapshot timeout though. Try the snapshotTimeout driver setting

@lubshilk
Copy link
Author

lubshilk commented Nov 13, 2019

There are so many problems with XCTest! Do you know if they will be fixed?

@lubshilk
Copy link
Author

I'll try to run with snapshotTimeout, thanks

@mykola-mokhnach
Copy link
Collaborator

pain

Apple made it and only Apple can fix it ;)

@mykola-mokhnach
Copy link
Collaborator

You can also try to set the defaultActiveApplication setting to the current app bundle identifier. This is not really necessary, but just to make sure the correct app is always selected

@mykola-mokhnach mykola-mokhnach added ThirdParty upstream problems XCUITest regarding xcuitest driver labels Nov 13, 2019
@3a4oT
Copy link

3a4oT commented Nov 13, 2019

we have the same issue and snapshotTimeout doesn't help. Then I set useJSONSource: true and I was able to bypass this issue, unfortunately, we faced the new one - only one element shown (XCUIElementTypeAny) by the inspector instead of a tree.

"automationName": "XCUITest",
 "platformVersion": "13.2",
 "snapshotTimeout": 30,
 "useJSONSource": true

Original error log:

[MJSONWP (36cb9c16)] Calling AppiumDriver.getPageSource() with args: ["36cb9c16-219e-44e3-987b-f382669e3d3c"]
[XCUITest] Executing command 'getPageSource'
[WD Proxy] Got response with status 200: {
[WD Proxy]   "value" : {
[WD Proxy]     "width" : 375,
[WD Proxy]     "height" : 667
[WD Proxy]   },
[WD Proxy]   "sessionId" : "C74499F6-F7CD-4FF8-A95A-EDFFA2AD18A2"
[WD Proxy] }
[XCUITest] Taking screenshot with WDA
[WD Proxy] Matched '/screenshot' to command name 'getScreenshot'
[WD Proxy] Proxying [GET /screenshot] to [GET http://localhost:8100/session/C74499F6-F7CD-4FF8-A95A-EDFFA2AD18A2/screenshot] with no body
[MJSONWP (36cb9c16)] Responding to client with driver.getWindowSize() result: {"width":375,"height":667}
[HTTP] <-- GET /wd/hub/session/36cb9c16-219e-44e3-987b-f382669e3d3c/window/current/size 200 2957 ms - 98
[HTTP] 
[WD Proxy] Got response with status 200: {
[WD Proxy]   "value" : "iVBORw0KGgoAAAANSUhEUgAAAu4AAAU2CAIAAABFtaRRAAAAAXNSR0IArs4c6QAA\r\nAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKAC\r\nAAQAAAABAAAC7qADAAQAAAABAAAFNgAAAACw0axrAAAAHGlET1QAAAACAAAAAAAA\r\nApsAAAAoAAACmwAAApsAAd8bDKJbxgAAQABJREFUeAHsnQeYXGd194Ulbe9dvUuW\r\nLNkGTGyDMQQSSkLAmNi4UI3pkIQktEBIQgrlCy4qW6bfqbsryepa7Wr77szs9LpN\r\n1Za75abedb\/fuXcli4CJRPJ9iazr533Go9lbz73nvP\/zP+WdVOxKXtGYtK5\/Sstg\r\nidtfoYQqlFiFI1muJMsdaUaJM13gjud643meWKE7VuKKlDsjV3TwixuXOJOMUkWG\r\n\/r3QlWQUuGUUutKMYqeMKb50rodTJ7kSrqdc4dRcQzJHRjrPnS1wZdm4wJ3mlym+\r\nK7tZrifPLfuWOOOlzji3wyhxxfhnsSuuX6HcvhJncL+MYneo0B0p8MTyPMlcTzbP\r\nPVzoHC5RsqVKWtsyVurUd5fb4cL0u\/v1T448MSYEot1psTMr4wqfl7H9W1sCKBoj\r\nz8srJ6+fvF2uGC8nKsAbyDuGBlU5YqhGgSeU6wsVOkd5i3iNK5zBctdgOZ+iv8Pl\r\n9tESZZRdcnwxNuM1rrGHZloiVYofnSpwjue49k327J3iHc31ckZOpJ+LF55T887H\r\nUMYSZRgtQ1+qbKNV1vE81+4czzgKiBKhpznebKljmD+VO7LYCk40uSVS7QhyMXme\r\nuK7Fmr7H+ay2DjNQHPSdv2JY0KAKexbt5vioVa57nE9du9EjDj7Fm+XsGJ8SV6jU\r\nFUII3P6kdaFJrbFc2XKUjbWjxThaMVrpGOeCkQbayuA94are2...
[WD Proxy] Matched '/source' to command name 'getPageSource'
[WD Proxy] Proxying [GET /source] to [GET http://localhost:8100/session/C74499F6-F7CD-4FF8-A95A-EDFFA2AD18A2/source] with no body
[MJSONWP (36cb9c16)] Responding to client with driver.getScreenshot() result: "iVBORw0KGgoAAAANSUhEUgAAAu4AAAU2CAIAAABFtaRRAAAAAXNSR0IArs4c6QAA\r\nAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKAC\r\nAAQAAAABAAAC7qADAAQAAAABAAAFNgAAAACw0axrAAAAHGlET1QAAAACAAAAAAAA\r\nApsAAAAoAAACmwAAApsAAd8bDKJbxgAAQABJREFUeAHsnQeYXGd194Ulbe9dvUuW\r\nLNkGTGyDMQQSSkLAmNi4UI3pkIQktEBIQgrlCy4qW6bfqbsryepa7Wr77szs9LpN\r\n1Za75abedb/fuXcli4CJRPJ9iazr533Go9lbz73nvP/zP+WdVOxKXtGYtK5/Sstg\r\nidtfoYQqlFiFI1muJMsdaUaJM13gjud643meWKE7VuKKlDsjV3TwixuXOJOMUkWG\r\n/r3QlWQUuGUUutKMYqeMKb50rodTJ7kSrqdc4dRcQzJHRjrPnS1wZdm4wJ3mlym+\r\nK7tZrifPLfuWOOOlzji3wyhxxfhnsSuuX6HcvhJncL+MYneo0B0p8MTyPMlcTzbP\r\nPVzoHC5RsqVKWtsyVurUd5fb4cL0u/v1T448MSYEot1psTMr4wqfl7H9W1sCKBoj\r\nz8srJ6+fvF2uGC8nKsAbyDuGBlU5YqhGgSeU6wsVOkd5i3iNK5zBctdgOZ+iv8Pl\r\n9tESZZRdcnwxNuM1rrGHZloiVYofnSpwjue49k327J3iHc31ckZOpJ+LF55T887H\r\nUMYSZRgtQ1+qbKNV1vE81+4czzgKiBKhpznebKljmD+VO7LYCk40uSVS7QhyMXme\r\nuK7Fmr7H+ay2DjNQHPSdv2JY0KAKexbt5vioVa57nE9du9EjDj7Fm+XsGJ8SV6jU\r\nFUII3P6kdaFJrbFc2XKUjbWjxThaMVrpGOeCkQbayuA94are2m+LcXeGBH63BPQ5\r\n...
[HTTP] <-- GET /wd/hub/session/36cb9c16-219e-44e3-987b-f382669e3d3c/screenshot 200 3016 ms - 270078
[HTTP] 
[WD Proxy] Got response with status 500: {
[WD Proxy]   "value" : {
[WD Proxy]     "error" : "unknown error",
[WD Proxy]     "message" : "Cannot get 'xml' source of the current application",
[WD Proxy]     "traceback" : ""
[WD Proxy]   },
[WD Proxy]   "sessionId" : "C74499F6-F7CD-4FF8-A95A-EDFFA2AD18A2"
[WD Proxy] }
[W3C] Matched W3C error code 'unknown error' to UnknownError
[MJSONWP (36cb9c16)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot get 'xml' source of the current application
[MJSONWP (36cb9c16)]     at errorFromW3CJsonCode (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:780:25)
[MJSONWP (36cb9c16)]     at ProxyRequestError.errorFromW3CJsonCode [as getActualError] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/protocol/errors.js:663:14)
[MJSONWP (36cb9c16)]     at JWProxy.getActualError [as command] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium-xcuitest-driver/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:259:19)
[HTTP] <-- GET /wd/hub/session/36cb9c16-219e-44e3-987b-f382669e3d3c/source 500 33700 ms - 221
[HTTP] 

@mykola-mokhnach
Copy link
Collaborator

mykola-mokhnach commented Nov 15, 2019

@lubshilk I've made several improvements to WDA recently, so now it is possible to get the xml source without including the visible attribute, which is usually the cause of snapshotting issues.
Reinstall appium@beta and request the source using mobile: source endpoint with arguments format: xml and excludedAttributes: visible

@lubshilk
Copy link
Author

@mykola-mokhnach Upgraded Appium to v1.16.0-beta.1 and used arguments as you suggested.
Got xml page source. Thanks :)
Could WDA be improved to catch elements by classname and id as well? ;) This is our original problem, we began to try to catch page source to verify what changed on the page and why elements are not found

@mykola-mokhnach
Copy link
Collaborator

Could WDA be improved to catch elements by classname and id as well?

What do you mean?

@jniosdeveloper
Copy link

@lubshilk Hello, I'd like to ask you a question. How do you run it on a real machine? After I clone WebDriverAgent and run it in Xcode 11.2, I can't compile successfully. An error (could not build module 'routinghttpserver') will be reported. WebDrivertAgent can't run, so I can't test it.

@lubshilk
Copy link
Author

lubshilk commented Nov 18, 2019

@mykola-mokhnach I needed pagesource to check why an element we are trying to find by classname reported as not found. It cleared in ios13 it shown differently from ios12 (the same page in application)
So it looks like no WDA, but again XCUItest problem :( So you cannot help here, right?

@lubshilk
Copy link
Author

@mykola-mokhnach Thanks for helping :)
When the next not-beta version is expected?

@lubshilk
Copy link
Author

@jniosdeveloper We don't build the WDA in Xcode app. It is built and installed on the real device by appium while creating a session

@mykola-mokhnach
Copy link
Collaborator

So it looks like no WDA, but again XCUItest problem :( So you cannot help here, right?

Yes, the tree itself is built by XCTest.

Closed as third party issue

@lubshilk
Copy link
Author

@mykola-mokhnach When the next not-beta version with mentioned WDA improvements is expected?

@mykola-mokhnach
Copy link
Collaborator

I cannot say the exact dates. As soon as we address known problems in iOS and Android

@GunkanjimaQA
Copy link

@lubshilk I've made several improvements to WDA recently, so now it is possible to get the xml source without including the visible attribute, which is usually the cause of snapshotting issues.
Reinstall appium@beta and request the source using mobile: source endpoint with arguments format: xml and excludedAttributes: visible

Quite an offtopic but is it possible to use these parameters when running Appium desktop with appium@beta 1.16? Maybe you can point the direction to dig?

@narasimhanukala
Copy link

narasimhanukala commented Nov 29, 2019

@lubshilk I've made several improvements to WDA recently, so now it is possible to get the xml source without including the visible attribute, which is usually the cause of snapshotting issues.
Reinstall appium@beta and request the source using mobile: source endpoint with arguments format: xml and excludedAttributes: visible

@mykola-mokhnach ,

Can you provide more details on how to use following attributes while using appium desktop?

mobile: source endpoint with arguments format: xml and excludedAttributes: visible

@narasimhanukala
Copy link

narasimhanukala commented Dec 2, 2019

@mykola-mokhnach Upgraded Appium to v1.16.0-beta.1 and used arguments as you suggested.
Got xml page source. Thanks :)
Could WDA be improved to catch elements by classname and id as well? ;) This is our original problem, we began to try to catch page source to verify what changed on the page and why elements are not found

@lubshilk ,
How did you use the arguments to resolve the xml structure issue?
mobile: source endpoint with arguments format: xml and excludedAttributes: visible

@lubshilk
Copy link
Author

lubshilk commented Dec 2, 2019

@narasimhanukala I didn't use it in Appium desktop
Code in Java:

HashMap<String,String> obj = new HashMap<String,String>();
obj.put("format", "xml");
obj.put("excludedAttributes", "visible");
String PageSource = ((JavascriptExecutor)driver).executeScript("mobile: source", obj).toString();

@narasimhanukala
Copy link

@narasimhanukala I didn't use it in Appium desktop
Code in Java:

HashMap<String,String> obj = new HashMap<String,String>();
obj.put("format", "xml");
obj.put("excludedAttributes", "visible");
String PageSource = ((JavascriptExecutor)driver).executeScript("mobile: source", obj).toString();

Hi @lubshilk , thanks for quick turnaround.
i don't think i need PageSource in my framework.
What exactly you are doing after getting pagesource??

@lubshilk
Copy link
Author

lubshilk commented Dec 2, 2019

@narasimhanukala I needed page source to check how an element is shown in our application on IOS13 device (In the same application on devices with IOS12 and IOS13 the same element can be shown differently by XCUItest)

@narasimhanukala
Copy link

@narasimhanukala I needed page source to check how an element is shown in our application on IOS13 device (In the same application on devices with IOS12 and IOS13 the same element can be shown differently by XCUItest)

Thanks @lubshilk

@czandler22
Copy link

@lubshilk I've made several improvements to WDA recently, so now it is possible to get the xml source without including the visible attribute, which is usually the cause of snapshotting issues.
Reinstall appium@beta and request the source using mobile: source endpoint with arguments format: xml and excludedAttributes: visible

I tried everything from this topic and nothing helped. Please help!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Info typically non-actionable; needs author to respond ThirdParty upstream problems XCUITest regarding xcuitest driver
Projects
None yet
Development

No branches or pull requests

7 participants