Suppose that we have a step definition like this:
public class CareersSteps extends StepDefinition {
WebDriver driver;
@Before
public void setUp() {
const XHR = require ('../ lib / xhr.js'); | |
const DOM = require ('../ lib / domUtils.js'); | |
function loader {container} { | |
const output = DOM.printTo (container); | |
XHR.get (href, content => { | |
let {content, js} = DOM.parse (content); | |
// ... | |
}); |
{ | |
1: ..., | |
2:[ | |
function(require, module, exports) { | |
const XHR = require('../lib/xhr.js'); | |
const DOM = require('../lib/domUtils.js'); | |
function carregador(container) { | |
const output = DOM.printTo(container); | |
const XHR = require('../lib/xhr.js'); | |
const DOM = require('../lib/domUtils.js'); | |
function carregador(container) { | |
const output = DOM.printTo(container); | |
XHR.get(href, conteudo => { | |
let { content, js } = DOM.parse(conteudo); | |
// ... | |
}); |
// requisitar dependência: | |
let a = require('a.js'); // Node.js modules | |
import a from 'a.js'; // ES modules | |
// ...seu código aqui... | |
// Uma dessas maneiras para tornar as coisas visiveis fora do módulo: | |
module.exports = algumaCoisa; // Node.js | |
export algumaCoisa; |
// minhaCamisa.js agora possui dependencias, o carrinho e o inventorio | |
// módulo no mesmo diretorio que camisa.js | |
define(["./carrinho", "./inventorio"], (carrinho, inventorio) => { | |
// retorna um objeto para definir o módulo "minhaCamisa". | |
return { | |
cor: "azul", | |
tamanho: "grande", | |
adicionarAoCarrinho: () => { | |
inventorio.decrementar(this); | |
carrinho.adicionar(this); |
let algumaCoisa = (() => { | |
// tão chamado "encapsulamento" aqui | |
// ... | |
// e então... | |
return { | |
primeiroPublico: ..., | |
segundoPublico: ... | |
}; | |
})(); |
require 'selenium-webdriver' | |
require_relative './pages/login' | |
describe 'Login' do | |
before(:each) do | |
chromedriver_path = File.join(File.absolute_path('../..', File.dirname(__FILE__)), "test", "browsers", "chromedriver") | |
Selenium::WebDriver::Chrome.driver_path = chromedriver_path | |
@driver = Selenium::WebDriver.for :chrome | |
@login = Login.new(@driver) |
class Login | |
LOGIN_FORM = { id: 'login' } | |
USERNAME_INPUT = { id: 'username' } | |
PASSWORD_INPUT = { id: 'password' } | |
SUCCESS_MESSAGE = { css: '.success' } | |
def initialize(driver) | |
@driver = driver | |
@driver.get 'http://selenium-bootcamp.herokuapp.com' |
require 'selenium-webdriver' | |
describe 'Login' do | |
before :each do | |
chromedriver_path = File.join(File.absolute_path('../..', File.dirname(__FILE__)), "test", "browsers", "chromedriver") | |
Selenium::WebDriver::Chrome.driver_path = chromedriver_path | |
@driver = Selenium::WebDriver.for :chrome | |
end |