Skip to content

Instantly share code, notes, and snippets.

Javier Gomez javigomez

View GitHub Profile
View page-object.rb
require 'rubygems'
require 'selenium-webdriver'
require 'page-object/page_factory'
require_relative 'pages/duckduckgo_page'
World(PageObject::PageFactory)
browser = Selenium::WebDriver.for :chrome
# browser.get "http://duckduckgo.com"
my_page_object = DuckduckgoSearchPage.new(browser)
@javigomez
javigomez / wait-for-grid.sh
Created Apr 20, 2018
Wait for Selenium Grid by @diemol
View wait-for-grid.sh
#!/bin/bash
# wait-for-grid.sh
set -e
cmd="$@"
while ! curl -sSL "http://hub:4444/wd/hub/status" 2>&1 \
| jq -r '.value.ready' 2>&1 | grep "true" >/dev/null; do
echo 'Waiting for the Grid'
View docker stuff
# PARAR CONTAINERs
docker-compose down
docker stop $(docker ps -q)
docker kill -f CONTAINER_ID
# LIMPIAR IMAGENES Y CONTENEDORES ANTIGUOS
docker system prune
docker volume prune
# ENTRAR EN CONTAINER
@javigomez
javigomez / multiple_choice_block.rb
Created Nov 23, 2017
multiple choice page object
View multiple_choice_block.rb
#file: features/support/pages/multiple_choice_block.rb
module MultipleChoiceBlock
include PageObject
divs(:choice_list, css: '.is-focused .stkv-qa-choice')
sections(:block_list, class: 'stkv-qa-block')
def commit_answer
self.choice_list_elements[selected_choice_id].click
end
View short_text_block.rb
# file: features/support/pages/short_text_block.rb
module InputTextBlock
include PageObject
text_field(:text_input, css: '.is-focused input')
button(:ok_button, css: '.is-focused .stkv-qa-block-btn.is-visible .stkv-qa-block-btn__button')
def commit_answer
self.fill_answer
View test_steps.rb
# file: features/step_definitions/test_step.rb
...
When(/^I (?:commit|have committed) the block$/) do
@current_progress_bar =
on_page(@block_type.to_page_object).commit_answer
end
View progress_bar_declarative_gherkin.feature
# file: features/acceptance/functionality/progress_bar_functionality.feature
Scenario Outline: Progress bar status if block is answered
Given I have visited a typeform with many <block type> blocks
When I commit the block
Then the progress bar should increase
Examples:
| block type |
| short text |
| multiple choice |
View progress_bar_imperative_gherkin.feature
Scenario: Progress bar status if block is answered
Given I have visited a typeform with 3 blocks
And the "What is your name" "short text" block is focused
When I answer "my name is Javi"
And I click "Ok button"
Then the progress bar should increase to 33%
Then the "How old are you" "number" block is focused
When I answer "35"
...
@javigomez
javigomez / progress_bar.feature
Created Nov 23, 2017
Progress Bar Feature Gherkin
View progress_bar.feature
Feature: Progress bar functionality
As a typeform user
I want to see the progress bar
So I know how many questions do I still have to answer
@javigomez
javigomez / nested.rb
Last active Oct 23, 2017
nested to_json in ruby
View nested.rb
# require 'active_support'
# require 'active_support/core_ext'
require 'json'
require 'values'
class Statement < Value.new(:title, :description)
def to_json(state = nil)
{
title: title,
properties: {
You can’t perform that action at this time.