1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
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.
Contenuto pertinente
- AWS UFFICIALEAggiornata 3 anni fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata un anno fa