Skip to content

Instantly share code, notes, and snippets.

View hanikhan's full-sized avatar

Hani Khan hanikhan

  • Ex Dream11, Ex BrowserStack
  • Mumbai India
View GitHub Profile
@hanikhan
hanikhan / browserstack.codecept.conf.js
Created November 27, 2017 11:41
codeceptJS configuration file for BrowserStack
exports.config={
helpers: {
WebDriverIO: {
url: process.env.BASE_URL,
user: "<USERNAME>",
key: "<ACCESS_KEY>",
desiredCapabilities: {
project: "Sample Project",
build: "CodeceptJS",
"browserstack.local" : true,
@hanikhan
hanikhan / gist:508e4af809b47de6b1a2a8c76eab3f3e
Last active April 9, 2018 01:32
Using BrowserStack with BrowserMob to capture HAR
/*This will need the following Dependencies
<dependency>
<groupId>com.browserstack</groupId>
<artifactId>browserstack-local-java</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core</artifactId>
@hanikhan
hanikhan / gist:a63b7df334ceaf7fd58a6e9c0c885391
Created December 13, 2017 07:46
BrowserStack Selenide sample using Gradle
/*
* Clone https://github.com/browserstack/selenide-browserstack
* Configure gradle globally OR locally in the project directory
* Use 'gradle init'
* Modify the build.gradle file inline with the below example
*/
apply plugin: 'java'
apply plugin: 'maven'
@hanikhan
hanikhan / gist:a828ceaee09bf327e184acb31012501f
Created December 13, 2017 11:12
Enable Flash on Chrome 62 (Python) - BrowserStack
#Replace username and access_key with your BrowserStack username and key
from selenium import webdriver
desired_cap = {'browser': 'Chrome', 'browser_version': '62', 'os': 'OS X', 'os_version': 'Sierra','browserstack.debug': 'true','build': 'Test Build v1.0'}
desired_cap['chromeOptions'] = { 'prefs' : {'profile': {"default_content_settings":{"multiple-automatic-downloads":1},"default_content_setting_values":{"automatic_downloads":1,"plugins":1},"content_settings":{"plugin_whitelist":{"adobe-flash-player":1},"exceptions":{"plugins":{"*,*":{"per_resource":{"adobe-flash-player":1}}}}},"password_manager_enabled":False,"gaia_info_picture_url":True}}}
driver = webdriver.Remote(
command_executor='http://<username>:<access_Key>@hub.browserstack.com:80/wd/hub',
desired_capabilities=desired_cap)
@hanikhan
hanikhan / gist:e74c59917ef51b69669b86991481d5f3
Created February 2, 2018 19:00
Integrate BrowserStack with Applitools - Java Sample
/*
Add the following dependency to your project OR download and add equivalent jar file to your project
<dependency>
<groupId>com.applitools</groupId>
<artifactId>eyes-selenium-java3</artifactId>
<version>RELEASE</version>
</dependency>
*/
import org.openqa.selenium.By;
@hanikhan
hanikhan / gist:781d04a20a422c0ceb074d15a7009c79
Created February 28, 2018 10:02
Parallel tests on same browsers
require('babel-register');
require('./fast-selenium.js');
const instances = 2;
const user = '<BrowserStack_Username>';
const key = '<BrowserStack_Key>';
const dt = new Date().getTime();
const buildName = 'BrowserStack Parallel Tests: ' + dt;
@hanikhan
hanikhan / gist:f2569d260917f81a239002720df8bd9d
Created March 6, 2018 08:54
Updated fast_selenium.py file to work with python3
# Pre-requisites:
# python3 -m pip install selenium
# python3 -m pip install urllib3
import base64
import http.client
import logging
import socket
import inspect
import string
@hanikhan
hanikhan / gist:dd5203d0b2db728d41bf5c43d4c05dfc
Created March 15, 2018 18:56
Setup Appium with real iOS devices on Mac OS X with Xcode 9.2 and iOS 11.2
Steps to run Appium locally on real iOS (Xcode 9.2 and iOS 11.2)
//Assuming you have homebrew and npm already setup & a valid Apple developer account
//these set of commands need to be run from terminal
- brew install libimobiledevice --HEAD # install from HEAD to get important updates
- brew install carthage
- npm install -g ios-deploy
- brew install ios-webkit-debug-proxy
- npm install -g appium
/*
Please add the following dependency in your pom.xml:
<dependency>
<groupId>com.browserstack</groupId>
<artifactId>browserstack-local-java</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
OR Download the jar from : https://mvnrepository.com/artifact/com.browserstack/browserstack-local-java/1.0.2 and add it to your project
@hanikhan
hanikhan / gist:88d4a0711ef5821128c5d098a2a6d3ff
Last active August 7, 2018 16:17
NativeWebTap on real iOS devices - Sample on BrowserStack
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class nativeTapSample {
public static final String USERNAME = "<BrowserStack_Username>";