如何从节点js中的元素执行getText()

时间:2019-02-05 22:41:25

标签: node.js selenium-webdriver

我期望使用硒节点js从元素中获取getText()

我尝试过

element(by.css('.download-recording .pgi-button-wrapper')).click();

browser.driver.wait(function() {

    return fs.existsSync('/home/user,/Downloads/Recordings/ProtractorMeeting-2019-01-24T21_56_24.000Z.mp4')}, 8000).then(function() {

        console.log("File Downloaded");
        console.log(fs.statSync('/home/user/Downloads/Recordings/ProtractorMeeting-2019-01-24T21_56_24.000Z.mp4').size);
        console.log(fs.readFileSync('/home/user/Downloads/Recordings/ProtractorMeeting-2019-01-24T21_56_24.000Z.mp4').length);
});

它返回了 driver.findElement(webdriver.By.className("testrunner-results-list js-testrunner-results-list")).getText().then((text)=>{ console.log(text);}); testcase3 testcase3

当我尝试时:

testcase3

它返回了var a = driver.findElement(webdriver.By.className("testrunner-results-list js-testrunner-results-list")).getText() console.log(a);

unpromising

我希望它能返回

driver.findElements(
    webdriver.By.className(
        "coral-Icon coral-Icon--chevronRight coral-Icon--sizeXS u-coral-pullRight"
    )
).then(elements => {
    for(n=0; n<elements.length; n++) {

        if(elements[n].isDisplayed() ) {
            elements[n].click().then(() => {
                driver.findElement(
                    webdriver.By.className(
                        "testrunner-results-list js-testrunner-results-list"
                    )
                ).getText()
                .then(text => { console.log(text) });
            })                          
        } else {
            /**Do this  */ 
        }
    }
})

但它正在返回

testcase1
testcase2
testcase3

0 个答案:

没有答案