Skip to content

Instantly share code, notes, and snippets.

@jefferson
Last active December 3, 2018 01:10
Show Gist options
  • Save jefferson/e5ec4b28175ad875333b94ece1261734 to your computer and use it in GitHub Desktop.
Save jefferson/e5ec4b28175ad875333b94ece1261734 to your computer and use it in GitHub Desktop.
Comandos mais utilizados no selenium-webdriver com nodejs
//Para utilizar os comandos abaixo não esqueça de utilizar os seguintes imports
const { driver } = require('../support/web_driver');
const { By } = require('selenium-webdriver');
//Acessar um URL
driver.get("https://localhost:5001/");
//Pesquisar por um elemento utilizando o xpath e clica no mesmo
await driver.findElement(By.xpath('//*[@id="cookieConsent"]/div/div[2]/div/button')).click();
//Pesquisa por um elemento utilizando o seletor css e clica no mesmo
await driver.findElement(By.css('body > nav > div > div > ul > li:nth-child(1) > a')).click();
//Aguardar por alguns segundos, em milissegundos, parando a execução do teste ate que o tempo sejá finalizado.
//Util para aguardar que um elemento esteja visível na tela.
driver.sleep(1000);
//Entra com dados em um elemento utilizando o id, neste caso.
await driver.findElement(By.id('Input_Email')).sendKeys('[email protected]');
//fim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment