Thursday, 16 March 2017

selenium-webdirver nodeJD - can't return string from object

I am trying to port my Selenium project out of Java and put in in NodeJS. So far the below is working, but I can't access any of the string methods from the selenium webdriver API Specifically the ones in webElements class.

The goal is to create an automated script that can auto fill out any form its given for re-usability. I want to get all inputs then filter which ones are checkboxs, radio, email etc.

// **main.ts**


let targetWebsite = "http://localhost:4200";

// Webdriver
let webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;

// Initialize the driver 
let driver = new webdriver.Builder()
        .forBrowser("firefox")
        .build();

// Start chrome webdriver 
driver.get(targetWebsite).then(function() {
    autoFormInputs(driver);
});

// Form automation
function autoFormInputs(driver) {
    driver.findElements(By.css("input")).then(function(elements) {
        elements.forEach(function (input) {
            item.click();
            item.sendKeys("Some text");
            //console.log(item.getText()); <- Returns an object of ManagedPromise??
            //console.log(item.getTagName()); <- Returns  an object of ManagedPromise??
        })
    });
    console.log("Finished executing tests");
}



via Paddy

No comments:

Post a Comment