Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
.venv
env
local.log
log/
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# vanilla-python-browserstack
We require the following new public repositories under the browserstack GitHub organization to host customer-facing sample projects for the BrowserStack SDK.
# Vanilla Python with BrowserStack SDK
26 changes: 26 additions & 0 deletions browserstack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
userName: YOUR_USERNAME
accessKey: YOUR_ACCESS_KEY
projectName: BrowserStack Samples
buildName: browserstack build
buildIdentifier: '#${BUILD_NUMBER}'
# Vanilla Python (python-generic) — no test framework; run via `browserstack-sdk python <script>`.
platforms:
- os: OS X
osVersion: Big Sur
browserName: Chrome
browserVersion: latest
- os: Windows
osVersion: 10
browserName: Edge
browserVersion: latest
- deviceName: Samsung Galaxy S22 Ultra
browserName: chrome
osVersion: 12.0
parallelsPerPlatform: 1
browserstackAutomation: true
browserstackLocal: true
source: vanilla-python-browserstack:sample-sdk:v1.0
testObservability: true
debug: false
networkLogs: false
consoleLogs: errors
19 changes: 19 additions & 0 deletions bstack_local_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Vanilla Python local test — verifies the BrowserStack Local tunnel.
from selenium import webdriver


def run():
driver = webdriver.Remote(
command_executor="https://hub.browserstack.com/wd/hub",
options=webdriver.ChromeOptions(),
)
try:
driver.get("http://bs-local.com:45454")
assert driver.title == "BrowserStack Local", driver.title
print("Vanilla Python local test passed.")
finally:
driver.quit()


if __name__ == "__main__":
run()
27 changes: 27 additions & 0 deletions bstack_sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Vanilla Python sample — no test framework. The BrowserStack SDK patches
# selenium webdriver.Remote at import time and runs this script across the
# platforms in browserstack.yml. Run: browserstack-sdk python bstack_sample.py
from selenium import webdriver
from selenium.webdriver.common.by import By


def run():
driver = webdriver.Remote(
command_executor="https://hub.browserstack.com/wd/hub",
options=webdriver.ChromeOptions(),
)
try:
driver.get("https://bstackdemo.com/")
product = driver.find_element(By.XPATH, '//*[@id="1"]/p').text
driver.find_element(By.XPATH, '//*[@id="1"]/div[4]').click()
driver.find_element(By.CLASS_NAME, "float-cart__content")
cart = driver.find_element(
By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]').text
assert cart == product, f"cart {cart!r} != product {product!r}"
print("Vanilla Python sample passed: cart matches product.")
finally:
driver.quit()


if __name__ == "__main__":
run()
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
selenium>=4.0.0
browserstack-local
browserstack-sdk @ https://sdk-assets.browserstack.com/python/browserstack_sdk-latest.tar.gz
Loading