使用JavaScript使用webdriver遍历表格的HTML行和列(量角器(非角度)) [英] Iterate through HTML rows and columns of a table using webdriver using javascript(Protractor non-angular)

查看:85
本文介绍了使用JavaScript使用webdriver遍历表格的HTML行和列(量角器(非角度))的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Selenium Webdriver遍历行和列(我在非角度网页上使用Protractor).我使用使用 WebElement 类的JAVA代码获得了执行此操作的链接数量.但是,我需要使用JavaScript代码来完成此操作.

I want to iterate through rows and columns using Selenium Webdriver (I am using Protractor for non-angular web page). I get number of links for doing this using JAVA code which uses WebElement class. However, I need to do this using JavaScript code.

谢谢,萨克什

推荐答案

以下工作有效:

browser.driver.findElement(by.id('table_id')).then(function(table){
    table.findElement(by.tagName('tbody')).then(function(tbody){
        tbody.findElements(by.tagName('tr')).then(function(rows){
            for(i=0; i<rows.length;i++)
            {
                rows[i].findElements(by.tagName('td')).then(function(cols){
                    expect(cols[2].getText()).toMatch('ok');
                });

            }

        });
    });
});

谢谢,萨克什

这篇关于使用JavaScript使用webdriver遍历表格的HTML行和列(量角器(非角度))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆