Device farm mshop automation : I am getting error related to chrome browser when I try to perform after webview switch

0

Hello,

I am executing mshop automation from my dev-desktop to device farm. When I perform webview switch and try to perfrom some action, I am getting below error :

2023-04-06 14:42:27 [main] INFO  — [GET_TEXT] {SOFTWARE_TITLE_ON_DP} 187ms Value: 'Microsoft 365 Personal | 12-Month Subscription, 1 person | Premium Office apps | 1TB OneDrive cloud storage | Windows/Mac (Email delivery in 2 hours-No CD)' BeforeWebViewSwitch url/dp/B08C85B28L 2023-04-06 14:42:52 [main] INFO  — Switched context to amazon.in by type PARTIAL_URL Webview switch done/dp/B08C85B28L 2023-04-06 14:42:52 [main] INFO  — [IS_PRESENT] {ADD_TO_CART} 90ms Value: 'true' org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: unknown error: operation is unsupported on Android (Session info: chrome=111.0.5563.116) (Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 3.13.0-170-generic x86_64) Build info: version: 'unknown', revision: 'unknown', time: 'unknown'


I am currently using Public devices. I have created a project and then created a device pool with same. I am currently using the free device minutes for execution. Can somebody help me in resolving this.

질문됨 일 년 전328회 조회
1개 답변
0

Hello, thank you for sharing your query. I believe you are facing errors in performing webview switch in chrome driver. You may try the below workaround which helps in installing the compatible Chrome Driver version to the Chrome Browser on the device :

1. First, add the attached file 'chromedriver-new-wrapper.txt ' to the root of your test package zip file.
2. Then, add the following code to your test spec file’s install phase in order to fix the $DEVICEFARM_CHROMEDRIVER_EXECUTABLE:
      - chrome_web_version=$(adb shell dumpsys package com.android.chrome    | grep versionName | cut -d"=" -f2|sort |tail -n 1)
      - >-
        if [ $(echo $chrome_web_version | cut -d"." -f 1) -ge 70 ];
        then
          proper_chromedriver_version=$(curl -L https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$(python    -c "import sys;print(\".\".join(sys.argv[-1].strip().split(\".\")[:-1]))" $chrome_web_version) 2> /dev/null )
          curl -L "https://chromedriver.storage.googleapis.com/$proper_chromedriver_version/chromedriver_linux64.zip   " -o /tmp/chromedriver_linux64_new.zip 2> /dev/null;
          unzip /tmp/chromedriver_linux64_new.zip -d /tmp >/dev/null;
          mv /tmp/chromedriver $(echo "$DEVICEFARM_CHROMEDRIVER_EXECUTABLE"-orig);
          rm -rf $DEVICEFARM_CHROMEDRIVER_EXECUTABLE;
          cp $DEVICEFARM_TEST_PACKAGE_PATH/chromedriver-new-wrapper* $DEVICEFARM_CHROMEDRIVER_EXECUTABLE;
          chmod +x $DEVICEFARM_CHROMEDRIVER_EXECUTABLE;
          $DEVICEFARM_CHROMEDRIVER_EXECUTABLE -v;
        else
          echo "Defaulting to devicefarm chromedriver version";
        fi;

Content of 'chromedriver-new-wrapper.txt ' (create the file with below content) :

#!/bin/bash
# Wrapper for chromedriver

sighandler() {
    pkill chromedriver-orig
    exit
}

trap sighandler SIGINT SIGTERM

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
LOG_FILE="/tmp/chromedriver_wrapper.log"
WRAPPER=$( basename "${BASH_SOURCE[0]}" )
POSTFIX="-orig"

if [ ! -f $LOG_FILE ]
then
  touch $LOG_FILE
  chmod 777 $LOG_FILE
fi

echo $DIR/${WRAPPER}${POSTFIX} $@ >> $LOG_FILE 

# Launch real chromedriver and parser on background so script could handle the signals
{
    $DIR/${WRAPPER}${POSTFIX} $@ 2>&1 | \
    while read line ; do
        echo $line
        # echo $line >> $LOG_FILE 
        port=$(echo "$line" | grep -Po '.*Received adb response:\K.*' | tr -d ' ')
        if [ -n "$port" ] && [ "$chrome_devtools_remote_port" != '' ];
        then
                echo "[CHROMEDRIVER-WRAPPER] Will Tunnel $port to $chrome_devtools_remote_port for $udid">> $LOG_FILE ;
                adb -s $udid forward tcp:$port $chrome_devtools_remote_port; # Uses ADB wrapper for forwarding
                chrome_devtools_remote_port="";
        else

            port=$(echo "$line" | grep -Po 'host-serial:.*:forward:tcp:\K.*?(?=;)')

            if [ -n "$port" ];
            then
                if [ "$port" -gt 1024 ];
                then
                    echo "[CHROMEDRIVER-WRAPPER] Will Tunnel $port">> $LOG_FILE ;
                    ip="$(ip -4 addr show eth0 | grep -Po '(?<=inet\s)\d+(\.\d+){3}')";
                    echo curl -H "Content-Type: application/json" -X POST -d '{"ip_address":"'"$ip"'","host_port":"'"$port"'","harness_port":"'"$port"'"}' http://localhost:31007/tunnel >> $LOG_FILE ;
                    curl -H "Content-Type: application/json" -X POST -d '{"ip_address":"'"$ip"'","host_port":"'"$port"'","harness_port":"'"$port"'"}' http://localhost:31007/tunnel >> $LOG_FILE 2>&1 ;
                else
                    chrome_devtools_remote_port=$(echo "$line" | grep -Po 'host-serial:.*;\K.*');
                    udid=$(echo "$line" | grep -Po 'host-serial:\K.*?(?=:)');
                    echo "[CHROMEDRIVER-WRAPPER] Preparing to Tunnel $chrome_devtools_remote_port for $udid">> $LOG_FILE ;
                fi;
            else
                port=$(echo "$line" |grep 'port'| grep -oP '\s*\d+\s*$'| grep -oP '\d+');

                if [ -n "$port" ] && [ "$port" -gt 1024 ];
                then
                    echo "[CHROMEDRIVER-WRAPPER] Will Tunnel $port">> $LOG_FILE ;
                    ip="$(ip -4 addr show eth0 | grep -Po '(?<=inet\s)\d+(\.\d+){3}')";
                    echo curl -H "Content-Type: application/json" -X POST -d '{"ip_address":"'"$ip"'","host_port":"'"$port"'","harness_port":"'"$port"'"}' http://localhost:31007/tunnel >> $LOG_FILE ;
                    curl -H "Content-Type: application/json" -X POST -d '{"ip_address":"'"$ip"'","host_port":"'"$port"'","harness_port":"'"$port"'"}' http://localhost:31007/tunnel >> $LOG_FILE 2>&1 ;
                fi
            fi
        fi
    done
} &

pid=$!
wait $pid

You need to define the $DEVICEFARM_CHROMEDRIVER_EXECUTABLE environment variable which is the the version of the Chrome browser.

Having said that, in case you face further challenges, please feel free to open a support case with AWS using the following link.

AWS
지원 엔지니어
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠