Skip to content

Instantly share code, notes, and snippets.

View alnutile's full-sized avatar

Alfred Nutile alnutile

View GitHub Profile
@alnutile
alnutile / behat.yml
Created December 31, 2013 11:29
behat.yml
iPad:
context:
class: 'FeatureContext'
extensions:
Behat\MinkExtension\Extension:
base_url: 'https://saucelabs.com'
javascript_session: 'selenium2'
goutte:
selenium2:
browser: ipad
@alnutile
alnutile / behat.yml
Created January 3, 2014 16:50
Timeout issue
default:
paths: { features: features, bootstrap: /Users/testuser/Drupal/behatpfizer/site/sites/all/modules/custom/behat_editor/behat/features/bootstrap/FeatureContext.php }
extensions: { Behat\MinkExtension\Extension: { default_session: selenium2, goutte: null, selenium2: null, base_url: 'http://behateditor.localvm.com', browser_name: safari, javascript_session: selenium2 }, Drupal\DrupalExtension\Extension: { blackbox: null, api_driver: drush, drush: { alias: digitalocean.behateditorp_production }, subcontexts: { paths: [/Users/alfrednutile/Drupal/behatpfizer/site/sites/all/modules/] } } }
saucelabs:
context: { class: FeatureContext }
extensions: { Behat\MinkExtension\Extension: { default_session: selenium2, selenium2: { browser: chrome, wd_host: 'testuser:[email protected]/wd/hub', capabilities: { platform: 'Windows 2012', browser: chrome, version: '31', name: 'Behat Tests Module:behat_batch Filename: behat_batch|48', command-timeout: '900', max-duration: '900' } } } }
@alnutile
alnutile / behat.yml
Created January 6, 2014 12:39
Screen Resolution
default:
paths: { features: features, bootstrap: /Users/test/Drupal/behattest/site/sites/all/modules/custom/behat_editor/behat/features/bootstrap/FeatureContext.php }
extensions: { Behat\MinkExtension\Extension: { default_session: selenium2, goutte: null, selenium2: null, base_url: 'http://www.tikosyn.com', browser_name: safari, javascript_session: selenium2 }, Drupal\DrupalExtension\Extension: { blackbox: null, api_driver: drush, drush: { alias: digitalocean.behateditorp_production }, subcontexts: { paths: [/Users/test/Drupal/behatpfizer/site/sites/all/modules/] } } }
saucelabs:
context: { class: FeatureContext }
extensions: { Behat\MinkExtension\Extension: { default_session: selenium2, selenium2: { browser: 'internet explorer', wd_host: 'alfrednutile2:[email protected]/wd/hub', capabilities: { platform: 'Windows 2012 R2', browser: 'internet explorer', version: '11', name: 'Behat Tests Module:behat_tests Filename: test.feature', screen-resolution: 144
@alnutile
alnutile / custom_step.php
Created January 6, 2014 20:09
Using Behat / Mink and Javascript / jQuery to test the height of an element
/**
* See if the element (name|label|id) is greater than the % of the window
*
* @Then /^the element "([^"]*)" should be "([^"]*)" percent or greater than the window$/
*/
public function theElementShouldBePercentOrGreaterThanTheWindow($arg1, $arg2)
{
//1. make sure the target exists
//2. get the height of the target
//3. compare it to the window height
@alnutile
alnutile / Vagrantfile
Last active January 2, 2016 17:19
Vagrant
# Vagrant version 2
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.hostname = 'rails-dev-box'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provision :puppet,
@alnutile
alnutile / behat.yml
Created January 10, 2014 13:41
Behat.yml with default javascript. So even if the test does not have @javascript it will open a browser and run the test.
default:
paths:
features: 'features'
extensions:
Behat\MinkExtension\Extension:
default_session: selenium2
goutte: ~
selenium2: ~
base_url: http://saucelabs.com/test/guinea-pig
browser_name: safari
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 00:57
No name iframe
/**
* Sets an iFrame ID to no_name_iframe if there is no ID. You can then add a Switch to iFrame step after it using the na_name_iframe ID.
*
* @Given /^I the set the iframe located in element with an id of "([^"]*)"$/
*/
public function iSetTheIframeLocatedInElementWithAnIdOf($element_id) {
$check = 1; //@todo need to check using js if exists
if($check <= 0) {
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 00:59
Dealing with HTML that has multiple form fields
/**
* @hidden
*
* @Then /^I fill in the form field with id "([^"]*)" number "([^"]*)" with the value of "([^"]*)"$/
*/
public function fillInTheFormFieldWithIDNumberWithTheValueOf($arg1, $arg2, $arg3)
{
$arg = $arg2 - 1; //most users do not start at 0
$form_field = $this->getMainContext()->getSession()->getPage()->findAll('css', $arg1);
if($form_field) {
@alnutile
alnutile / behat.inc.php
Created January 11, 2014 01:02
Allow user to submit a form with no submit button
/**
* Some forms do not have a Submit button just pass the ID
*
* @Given /^I submit the form with id "([^"]*)"$/
*/
public function iSubmitTheFormWithId($arg)
{
$node = $this->getMainContext()->getSession()->getPage()->find('css', $arg);
if($node) {
$this->getMainContext()->getSession()->executeScript("jQuery('$arg').submit();");
@alnutile
alnutile / alert.php
Last active July 1, 2016 21:01
Dealing with Alerts
/**
* @hidden
*
* @Then /^I click on the alert window$/
*/
public function iClickOnTheAlertWindow() {
$this->getMainContext()->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}