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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Files
=====

* `bitbar_selenium.py` contains the sample unittest that opens the BitBar sample page, verifies the result text, and saves screenshots locally.
* `Requirements.txt` contains the required Python package versions for this sample.
* `screenshots/` is created when the test runs and stores the captured images.

Prerequisites
Expand All @@ -19,25 +20,19 @@ Prerequisites
Setup
=====

Install Selenium with one of the following options:
Install dependencies from `Requirements.txt`:

```bash
python3 -m pip install selenium
python3 -m pip install -r Requirements.txt
```

If your Python installation is managed by Homebrew and blocks global installs, use either a virtual environment or the explicit override:
If your Python installation is managed by Homebrew and blocks global installs, use:

```bash
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install selenium
python3 -m pip install --break-system-packages --user -r Requirements.txt
```

or

```bash
python3 -m pip install --break-system-packages selenium
```
For this sample to run without any code changes, use the package versions defined in `Requirements.txt`.

Then set your BitBar API key in the test capabilities in `bitbar_selenium.py`.

Expand Down Expand Up @@ -67,4 +62,7 @@ Troubleshooting

* `ModuleNotFoundError: No module named 'selenium'` means Selenium is not installed for the Python interpreter you used to launch the test.
* `SessionNotCreatedException: Full authentication is required to access this resource` usually means the BitBar API key is missing, invalid, or expired.
* `TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'` means incompatible package versions are installed. Reinstall dependencies from `Requirements.txt`.
* `ValueError: Timeout value connect was <object object ...>` usually means `urllib3` is too new for this sample. Reinstall dependencies from `Requirements.txt`.
* `DeprecationWarning` messages from Selenium 3 internals can appear with newer Python versions and are non-blocking.
* The sample saves screenshots into the local `screenshots` folder in the current working directory.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
selenium==3.141.0
urllib3<2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Ruby Selenium Sample

This folder contains a Ruby Selenium example script:

- `bitbar_selenium.rb`

## Prerequisites

- Ruby installed
- Gems installed (from this folder):

```bash
bundle install
```

## Run

From the repository root:

```bash
ruby samples/testing-frameworks/desktop-browsers/client-side/ruby/bitbar_selenium.rb
```

Or from this folder:

```bash
ruby bitbar_selenium.rb
```

## Expected Output

When successful, the script prints page title text similar to:

- Bitbar - Test Page for Samples
- Bitbar
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# BitBar Selenium C# Sample

This folder contains a C# NUnit Selenium sample

## Prerequisites

- .NET SDK installed (current project targets `net10.0`/`net7.0`)
- A valid BitBar API key


## Files

- `UnitTest1.cs`: Main sample test
- `BitbarSeleniumSampleCSharp.csproj`: Project file and dependencies

## Run the test

From this folder:

```bash
dotnet test BitbarSeleniumSampleCSharp.csproj
```

## Configure BitBar

Update capabilities in `UnitTest1.cs` as needed:

- platformName
- browserVersion
- bitbar:options (project, testrun, apiKey, osVersion, resolution)


## Corner Cases / Troubleshooting

- SDK version mismatch (`NETSDK1045`):
If your local SDK does not support the target framework, install a compatible SDK or change the target framework in `BitbarSeleniumSampleCSharp.csproj`.

Example to install/check SDK:

```bash
dotnet --list-sdks
```

- Need to update Selenium WebDriver version:
If tests fail after browser or API-side changes, update `Selenium.WebDriver` to a newer compatible version.

```bash
dotnet add BitbarSeleniumSampleCSharp.csproj package Selenium.WebDriver --version 4.33.0
dotnet restore
```

- Package restore/build issues after version change:
Clean and restore dependencies before running tests again.

```bash
dotnet clean BitbarSeleniumSampleCSharp.csproj
dotnet restore BitbarSeleniumSampleCSharp.csproj
dotnet test BitbarSeleniumSampleCSharp.csproj
```
53 changes: 53 additions & 0 deletions samples/testing-frameworks/selenium/client-side/NodeJS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Selenium NodeJS Sample

This folder contains a sample client-side Selenium test for desktop browsers in BitBar Cloud.

## Files

- `bitbar_selenium.js` runs a Selenium WebDriver session against the BitBar desktop hub, opens the sample page, clicks the button, and validates the page title, result text, and button style.
- `package.json` defines the Node.js dependencies for the sample.

## Requirements

- Node.js
- npm
- A valid BitBar API key

## Dependencies

This sample uses the dependencies declared in `package.json`:

- `selenium-webdriver` `^4.28.1`
- `chai` `^5.1.2`

## Before Running

Open `bitbar_selenium.js` and replace the `apiKey` value with your own BitBar API key.

Install the project dependencies from this folder:

```bash
npm install
```

## Run Locally

From this folder, run:

```bash
node bitbar_selenium.js
```

## Expected Output

A successful run prints output similar to:

Bitbar - Test Page for Samples
Bitbar


## Troubleshooting

If `npm install` fails, verify that `node` and `npm` are installed and available in your shell.

If the test starts but fails to create a remote session, check that the BitBar `apiKey` in `bitbar_selenium.js` is valid.
48 changes: 48 additions & 0 deletions samples/testing-frameworks/selenium/client-side/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Intro
=====

This folder contains a sample client side Selenium test for desktop browsers in BitBar Cloud.
To run the sample, go to `https://cloud.bitbar.com/` and use a valid Bitbar API key.

Folder Content
--------------

This folder contains the following files:

* `src/test/java/com/bitbar/selenium/BitbarSelenium.java` is the Java sample test.

* `pom.xml` defines the Maven project and pulls the Selenium Java dependency used by the sample.

Requirements
------------

* Java 8 or newer
* Maven 3.6 or newer
* A valid Bitbar API key

Before Running
--------------

Add your BitBar Key here in BitbarSelenium.java:-
* `bitbarOptions.put("apiKey", "<insert your Bitbar API key here>");`

Run Locally
-----------

From this folder, run:

```bash
mvn -q -DskipTests test-compile org.codehaus.mojo:exec-maven-plugin:3.6.0:java \
-Dexec.mainClass=com.bitbar.selenium.BitbarSelenium \
-Dexec.classpathScope=test
```

Expected Output
---------------

A successful run prints output similar to:

```text
Bitbar - Test Page for Samples
Bitbar
```
27 changes: 27 additions & 0 deletions samples/testing-frameworks/selenium/client-side/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Selenium Python Sample

1. Open `bitbar_selenium.py` and update `apiKey` in `capabilities`.
2. Install compatible Selenium:
3. Run:

```bash
python3 bitbar_selenium.py
```

## Common Error

Error:

```text
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'
```

Cause:
- Installed Selenium version is too new for this sample code.

Fix:

```bash
python -m pip install "selenium==4.9.1"
(any selenium version that is compatible)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bitbar_device = Apple iPhone 16 A3287 26.2
browser_name = safari
platform_name = iOS
device_name = iPhone device
automation_name = XCUITest
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bitbar_device = Google Pixel XL
browser_name = chrome
platform_name = Android
device_name = Android Phone
automation_name = UiAutomator2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bitbar_device = Samsung Galaxy S24 Ultra SM-S928B
browser_name = chrome
platform_name = Android
device_name = Android Phone
automation_name = UiAutomator2