APP mixed native and H5 page, appium those things and X5 kernel

The new version of the measure mentioned, said that the development of a new version of the R & D needs "APP browser kernel into X5", what? Well, you have the final say.

As usual the new version running from automation, put there quietly run.

After a period of time to look at the report, what's up, webview related use cases, how have failed. Is it because the kernel changed the positioning element has changed.

Re-use uiautomatorviewer positioning time, positioning elements can not, can not use appium inspecto positioning. . . Look ignorant

Replaced weditor try to locate, but the same as the original positioning elements ah, what the situation?

So find a panacea google Baba, there have been a bunch of answers, it really is a problem X5 kernel.

 

---------------------------- ------------------- gorgeous dividing line ---------

Solution, summed up their own

APP because it is used by the kernel is the X5, so following my first step directly overlooked (if it is a small micro-channel program, it is useful)

 

Premise: the need to develop children's shoes turn webview function of APP

Open the way

Arranged in the following code app (static method call in setWebContentsDebuggingEnabled WebView class):

1
2
if (Build.VERSION.SDK_INT >=Build.VERSION_CODES.KITKAT) {  
WebView.setWebContentsDebuggingEnabled(true);

 

 

Step one: how to open x5 kernel debugging?

  • Enter any micro-channel chat window  debugx5.qq.com
  • Open the page by checking the Inspector open TBS kernel debugging features
  • Automatically take effect after restart

Step two: Check the current webview page element

  • Enter the page to be located, accessed using the chrome browser chrome: // inspect / # devices (If it does not need over the wall), you can see several processes including the com.tencent.mm, the numbers are in parentheses mark chrome representing the current version of Android, find the corresponding page, click inspect to see the elements of the page
  • TBS by Tencent debugging tools to download and install, according to the prompts TBS tool (not practical)

Step Three: positioning element

  • F12 developer tools, locate specific elements, right-click copy-copy xpath, can be obtained xpath element corresponding to the path.

Step Four: Modify the script

  (AndroidPackage androidProcess and package names corresponding to the APP, in general, the two are the same)    

"recreateChromeDriverSessions" = True
"chromeOptions"= {
            "androidPackage": "com.changyinshow", "androidProcess": "com.changyinshow"
        }

 

  • Before positioning elements plus

print (driver.contexts) obtain a context, which will generally return a list comprising webview. E.g. Returns: [ 'NATIVE_APP', 'WEBVIEW_com.changyinshow'], wherein WEBVIEW_com.changyinshow what you want to cut webview

driver._switch_to.context ( "WEBVIEW_com.changyinshow") to the corresponding switching webview

  • After adding the above code, the operation can continue subsequent elements

Special Note:

APP is based on google browser kernel, all the other cores are google secondary development version, we need the corresponding version chromedriver and chrome of your appium

appium run log can be seen in the chrome version of APP, visit chrome with chrome browser: // inspect / # devices can also see the version number of chrome

 

appium relationship chrome version of chromedriver and corresponding document can be viewed in chromedriver.js

 

 (Appium installation path is not clear, you can, or find a response file path by locate Chromedriver.js by which appium query path)

chromedriver download link:

https://chromedriver.storage.googleapis.com/index.html

or

http://npm.taobao.org/mirrors/chromedriver/

After the download, unzip, under chromedriver path into appium installation path (my mac installation path)

/Users/a/.nvm/versions/node/v8.11.0/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac

 

Traps: Why do you want to switch all webview

  • And selenium can be understood in a similar iframe
  • There is a clear indication on the right is positioned in WebView
  • After clicking on a link, there is a progress bar after the page loads are generally Webview. In other words, the page is a H5
  • UI Automator elements can not be located inside the

 

Reference Documents

https://zhuanlan.zhihu.com/p/81588023

https://www.cnblogs.com/longronglang/p/10276713.html

 

Automation problem applets can be micro-channel reference

https://www.cnblogs.com/longronglang/p/10276713.html

 

Guess you like

Origin www.cnblogs.com/wx2017/p/12170874.html