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

Not printing web view context through "print(driver.context)" command #938

Open
SantJen opened this issue Dec 11, 2023 · 13 comments
Open

Not printing web view context through "print(driver.context)" command #938

SantJen opened this issue Dec 11, 2023 · 13 comments

Comments

@SantJen
Copy link

SantJen commented Dec 11, 2023

The problem

Not printing context through "print(driver.context)" statement

Environment

Package Version


Appium-Python-Client 2.1.4
async-generator 1.10
attrs 22.1.0
certifi 2022.9.24
cffi 1.15.1
charset-normalizer 2.0.12
cryptography 38.0.1
cx-Oracle 8.3.0
cycler 0.11.0
fonttools 4.37.3
h11 0.14.0
idna 3.4
kiwisolver 1.4.4
matplotlib 3.5.3
natsort 8.3.0
numpy 1.21.6
outcome 1.2.0
packaging 21.3
Pillow 9.2.0
pip 21.3.1
pycparser 2.21
pyOpenSSL 22.1.0
pyparsing 3.0.9
PySocks 1.7.1
python-dateutil 2.8.2
PyYAML 6.0
requests 2.26.0
robotframework 4.1.2
robotframework-pabot 2.13.0
robotframework-stacktrace 0.4.1
selenium 4.0.0
setuptools 60.2.0
six 1.16.0
sniffio 1.3.0
sortedcontainers 2.4.0
trio 0.21.0
trio-websocket 0.9.2
typing_extensions 4.3.0
urllib3 1.26.12
urllib3-secure-extra 0.1.0
wheel 0.37.1
wsproto 1.2.0
Python 3.11

Details

Link to Appium Logs

Code To reproduce issue

def web_view_loc(driver, locator, value):
webview_context = None
print(driver.contexts)
time.sleep(180)

@SantJen SantJen changed the title Not printing context through "print(driver.context)" command Not printing web view context through "print(driver.context)" command Dec 11, 2023
@KazuCocoa
Copy link
Member

Please attache the appium server log as well

@SantJen
Copy link
Author

SantJen commented Dec 12, 2023

i am checking same with bs team,once get update i will share same

@SantJen
Copy link
Author

SantJen commented Dec 14, 2023

Appium logs.txt
Pls find the appium log attached here.
Thanks

@KazuCocoa
Copy link
Member

For below one?

2023-12-01 08:54:03:370 - [debug] [XCUITestDriver@97d6 (de487725)] [XCUITestDriver@97d6 (de487725)] No web frames found.
2023-12-01 08:54:03:370 - [debug] [XCUITestDriver@97d6 (de487725)] [XCUITestDriver@97d6 (de487725)] Responding to client with driver.getContexts() result: ["NATIVE_APP"]
2023-12-01 08:54:03:375 - [HTTP] [HTTP] <-- GET /wd/hub/session/de487725-3108-4ac9-a0fc-35adaf21ad7b/contexts 200 156 ms - 24
2023-12-01 08:55:39:670 - [debug] [RemoteDebugger] [RemoteDebugger] Selected app after 13ms
2023-12-01 08:55:39:671 - [debug] [XCUITestDriver@97d6 (de487725)] [XCUITestDriver@97d6 (de487725)] Responding to client with driver.getContexts() result: ["NATIVE_APP","WEBVIEW_2487.7"]
2023-12-01 08:55:39:671 - [HTTP] [HTTP] <-- GET /wd/hub/session/de487725-3108-4ac9-a0fc-35adaf21ad7b/contexts 200 15 ms - 41

In the XCUITest driver, appium gets these info via WebInspecor on the host machine. It could take a few seconds to get full contexts. So retrying a couple of times, of using https://appium.github.io/appium-xcuitest-driver/5.12/execute-methods/#mobile-getcontexts to get the context with waitForWebviewMs might help.

Or setting appium:webviewConnectTimeout in the capability also might help. https://appium.github.io/appium-xcuitest-driver/5.12/capabilities/

@SantJen
Copy link
Author

SantJen commented Jan 2, 2024

image
Hi,
can you tell me how to use "waitForWebviewMs" ,not getting from above info,
Thanks

@KazuCocoa
Copy link
Member

As the example below in the already attached documentation https://appium.github.io/appium-xcuitest-driver/5.12/execute-methods/, you could send it as driver.execute_script{'mobile: getContexts', {'waitForWebviewMs': 1000}}

# Python
result = driver.execute_script('mobile: <methodName>', {
    'arg1': 'value1',
    'arg2': 'value2',
})

@SantJen
Copy link
Author

SantJen commented Jan 3, 2024

Hi,
I used following code
"print(driver.execute_script('mobile: getContexts', {'waitForWebviewMs': 1000}))"
showing out put like bleow
"[{'id': 'NATIVE_APP'}]"
Pls have a look for same.
Thanks

@KazuCocoa
Copy link
Member

It indicates no webview found in 1000ms. Some cases it could need more longer time to wait (this is not controllable area by Appium).
If it keeps showing no webview, it perhaps indicate no webview info available via WebInspector

@SantJen
Copy link
Author

SantJen commented Jan 3, 2024

but web view there, if i check manually, pls suggest how to get web view through script

@SantJen
Copy link
Author

SantJen commented Jan 3, 2024

even I configured 5000ms , same issue like webview context not showing through script

@KazuCocoa
Copy link
Member

web view there

Do you mean the web view was WebInspector inspectable and could be found by the host OS's Web inspector? I'm not sure what communication occurred between Appium and macOS's Web Inspector (which appium gets WebView related data from), but basically the result depends on how macOS's Web Inspector respond to Appium.

https://appium.github.io/appium-xcuitest-driver/5.12/setup/
https://github.com/appium/appium-xcuitest-driver/blob/d2175c14304e88c6caee46d7e3f0793f03953abe/lib/commands/context.js#L187

The full appium log related to the request may help to see what occurred.

@SantJen
Copy link
Author

SantJen commented Jan 5, 2024

Downloads.zip
Hi,
Please find both logs attached here.
Thanks

@KazuCocoa
Copy link
Member

Did the webview accessible via WebInspector?
https://appium.github.io/appium-xcuitest-driver/5.14/setup/
https://appium.github.io/appium-xcuitest-driver/5.14/device-preparation/

It looks like the script execution and manual setup log used different devices. Please compare the same environment to reduce diffs on the device level. I guess the script execution hasn't configured Web Inspector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants