This repository has been archived on 2025-03-19. You can view files and clone it, but cannot push or open issues or pull requests.
TwitToMast/ref/functions/elements.js
Penelope Gomez / Pogmommy ed9d5c68fd 2.0.0
2023-02-14 14:35:57 -07:00

37 lines
906 B
JavaScript

const webdriver = require('selenium-webdriver');
const By = webdriver.By;
const until = webdriver.until;
async function doesExist(drvr,path){
exists = drvr.findElement(By.xpath(path)).then(function() {
return true; // It existed
}, function(err) {
if (err instanceof webdriver.error.NoSuchElementError) {
return false; // It was not found
}
});
return exists;
}
async function waitFor(drvr,xpath,ms){
await drvr.wait(until.elementLocated(By.xpath(xpath)), ms);
}
async function getAttribute(drvr,xpath,attribute){
return drvr.findElement(By.xpath(xpath)).getAttribute(attribute);
}
async function getText(drvr,xpath){
return drvr.findElement(By.xpath(xpath)).getText();
}
async function getElement(drvr,xpath){
return drvr.findElement(By.xpath(xpath));
}
module.exports = { doesExist,waitFor,getAttribute,getText,getElement };