Skip to content

Commit 7fcd35d

Browse files
committed
Mobile Script Changes
2 parents 26ccf14 + 67ca2f8 commit 7fcd35d

File tree

4 files changed

+81
-13
lines changed

4 files changed

+81
-13
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,17 @@ You can either run the script directly from the web or clone the repository and
3434

3535
**macOS / Linux**
3636
```bash
37-
bash mac.sh or ./mac.sh
37+
bash mac/run.sh or ./mac/run.sh
3838
```
39-
Incase there are any permission related issues, please run: chmod +x ./mac.sh
39+
If you encounter any permission issues, ensure the script is executable:
40+
41+
```
42+
chmod +x ./mac/run.sh
43+
```
44+
4045
**Windows**
4146
```powershell
42-
./windows.ps1
47+
./win/run.ps1
4348
```
4449

4550
### Remote Execution
@@ -49,7 +54,7 @@ You can either run the script directly from the web or clone the repository and
4954
To run the onboarding utility on macOS or Linux without cloning, execute the following command in your terminal:
5055

5156
```bash
52-
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/http-heading/browserstack-now/main/mac_os.sh)"
57+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/http-heading/browserstack-now/main/mac/run.sh)"
5358
```
5459

5560
#### Windows
@@ -58,7 +63,7 @@ To run the onboarding utility on Windows without cloning, execute the following
5863
**Note:** You may need to set the execution policy to `RemoteSigned` or `Bypass` to run the script.
5964

6065
```powershell
61-
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/http-heading/browserstack-now/main/windows.ps1'))
66+
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/http-heading/browserstack-now/main/win/run.ps1'))
6267
```
6368

6469
## Identifying and sharing the log files

mac/proxy-check.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env sh
2+
3+
# URL to test
4+
TEST_URL="https://www.browserstack.com/automate/browsers.json"
5+
6+
# Detect proxy from env (case insensitive)
7+
PROXY="${http_proxy:-${HTTP_PROXY:-${https_proxy:-${HTTPS_PROXY}}}}"
8+
9+
# Reset output variables
10+
export PROXY_HOST=""
11+
export PROXY_PORT=""
12+
13+
# Function: parse proxy url to host + port
14+
parse_proxy() {
15+
p="$1"
16+
# strip protocol e.g. http://, https://
17+
p="${p#http://}"
18+
p="${p#https://}"
19+
# strip credentials if any user:pass@
20+
p="${p#*[@]}"
21+
22+
# extract host and port
23+
export PROXY_HOST="${p%%:*}"
24+
export PROXY_PORT="${p##*:}"
25+
}
26+
27+
base64_encoded_creds=$(printf "%s" $BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY | base64 | tr -d '\n')
28+
29+
30+
# If no proxy configured, exit early
31+
if [ -z "$PROXY" ]; then
32+
echo "No proxy found in environment. Clearing proxy host and port variables."
33+
export PROXY_HOST=""
34+
export PROXY_PORT=""
35+
return 0 2>/dev/null || exit 0
36+
fi
37+
38+
echo "Proxy detected: $PROXY"
39+
parse_proxy "$PROXY"
40+
41+
echo "Testing reachability via proxy..."
42+
43+
44+
STATUS_CODE=$(curl -sS -o /dev/null -H "Authorization: Basic ${base64_encoded_creds}" -w "%{http_code}" --proxy "$PROXY" "$TEST_URL" 2>/dev/null)
45+
46+
if [ "${STATUS_CODE#2}" != "$STATUS_CODE" ]; then
47+
echo "✅ Reachable. HTTP $STATUS_CODE"
48+
echo "Exporting PROXY_HOST=$PROXY_HOST"
49+
echo "Exporting PROXY_PORT=$PROXY_PORT"
50+
export PROXY_HOST
51+
export PROXY_PORT
52+
else
53+
echo "❌ Not reachable (HTTP $STATUS_CODE). Clearing variables."
54+
export PROXY_HOST=""
55+
export PROXY_PORT=""
56+
fi

mac.sh renamed to mac/run.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,25 @@ APP_URL=""
2626
APP_PLATFORM="" # ios | android | all
2727

2828

29+
<<<<<<< HEAD:mac.sh
2930
# ===== Error Patterns =====
3031
WEB_SETUP_ERRORS=("Work in Progress")
3132
WEB_LOCAL_ERRORS=("Work in Progress")
3233

3334
MOBILE_SETUP_ERRORS=("Work in Progress")
3435
MOBILE_LOCAL_ERRORS=("Work in Progress")
3536

37+
=======
38+
>>>>>>> 67ca2f8a83425109951e581354969d419862d844:mac/run.sh
3639
# ===== Example Platform Templates (replace with your full lists if available) =====
3740
WEB_PLATFORM_TEMPLATES=(
3841
"Windows|10|Chrome"
3942
"Windows|10|Firefox"
4043
"Windows|11|Edge"
4144
"Windows|11|Chrome"
4245
"Windows|8|Chrome"
43-
#"OS X|Monterey|Safari"
4446
"OS X|Monterey|Chrome"
4547
"OS X|Ventura|Chrome"
46-
#"OS X|Big Sur|Safari"
4748
"OS X|Catalina|Firefox"
4849
)
4950

@@ -192,7 +193,6 @@ APP_URL=""
192193
APP_PLATFORM="" # ios | android | all
193194

194195

195-
196196
# ===== Log files (runtime only; created on first write) =====
197197
# ===== Log files (per-run) =====
198198
LOG_DIR="$WORKSPACE_DIR/$PROJECT_FOLDER/logs"
@@ -879,7 +879,7 @@ setup_web_nodejs() {
879879
local_flag=true
880880
fi
881881

882-
Log local flag status
882+
#log_msg_to local flag status
883883
if [ "$local_flag" = "true" ]; then
884884
log_msg_to "✅ BrowserStack Local is ENABLED for this run." "$PRE_RUN_LOG_FILE"
885885
else
@@ -892,7 +892,7 @@ setup_web_nodejs() {
892892
export BROWSERSTACK_LOCAL=$local_flag
893893

894894
# === 8️⃣ Run Tests ===
895-
log_msg_to "🚀 Running 'npm run test'" "$GLOBAL" "$WEB_LOG_FILE"
895+
log_msg_to "🚀 Running 'npm run test'. This could take a few minutes. Follow the Automaton build here: https://automation.browserstack.com/" "$WEB_LOG_FILE"
896896
npm run test >> "$WEB_LOG_FILE" 2>&1 || true
897897

898898
# === 9️⃣ Wrap Up ===
@@ -1079,13 +1079,13 @@ PYEOF
10791079

10801080
# Log local flag status
10811081
if [ "$local_flag" = "true" ]; then
1082-
log_msg_to "⚠️ BrowserStack Local is ENABLED for this run." "$PRE_RUN_LOG_FILE"
1082+
log_msg_to "⚠️ BrowserStack Local is ENABLED for this run."
10831083
else
1084-
log_msg_to "⚠️ BrowserStack Local is DISABLED for this run." "$PRE_RUN_LOG_FILE"
1084+
log_msg_to "⚠️ BrowserStack Local is DISABLED for this run."
10851085
fi
10861086

10871087
# Run pytest with BrowserStack SDK from the chosen platform directory
1088-
log_msg_to "🚀 Running 'cd $run_dir && browserstack-sdk pytest -s bstack_sample.py'" "$PRE_RUN_LOG_FILE"
1088+
log_msg_to "🚀 Running 'cd $run_dir && browserstack-sdk pytest -s bstack_sample.py'"
10891089
(
10901090
cd "$run_dir" && browserstack-sdk pytest -s bstack_sample.py >> "$log_file" 2>&1 || true
10911091
)
@@ -1325,5 +1325,12 @@ fetch_plan_details
13251325
# Plan summary in pre-run log
13261326
# log_msg_to "Plan summary: WEB_PLAN_FETCHED=$WEB_PLAN_FETCHED (team max=$TEAM_PARALLELS_MAX_ALLOWED_WEB), MOBILE_PLAN_FETCHED=$MOBILE_PLAN_FETCHED (team max=$TEAM_PARALLELS_MAX_ALLOWED_MOBILE)" "$GLOBAL"
13271327
log_msg_to "Plan summary: WEB_PLAN_FETCHED=$WEB_PLAN_FETCHED (team max=$TEAM_PARALLELS_MAX_ALLOWED_WEB), MOBILE_PLAN_FETCHED=$MOBILE_PLAN_FETCHED (team max=$TEAM_PARALLELS_MAX_ALLOWED_MOBILE)" "$GLOBAL"
1328+
<<<<<<< HEAD:mac.sh
1329+
=======
1330+
log_msg_to "Checking proxy in environment" "$GLOBAL"
1331+
chmod +x proxy-check.sh
1332+
./proxy-check.sh
1333+
log_msg_to "Starting setup run..." "$GLOBAL"
1334+
>>>>>>> 67ca2f8a83425109951e581354969d419862d844:mac/run.sh
13281335
run_setup
13291336
log_msg_to "Setup run finished." "$GLOBAL"
File renamed without changes.

0 commit comments

Comments
 (0)