java特定的表记录Seleniu\u表头的点击顺序不同

yqkkidmi  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(130)

根据下拉列表中的选择,下表标题更改意味着订单/位置发生变化。

以下代码仅在表标题为静态时有效。标题顺序更改时如何选择/单击特定记录?

public void productFilter(By tableLocator, By rowLocator, String openDate, String product, String status)
{
    IWebElement tableElement = DriverManager.driver.FindElement(tableLocator);
    IList<IWebElement> trElements = DriverManager.driver.FindElements(rowLocator);
    int rowCount = trElements.Count;
    for (int i = 0; i < rowCount; i++)
    {
        IList<IWebElement> tdElements = trElements[i].FindElements(By.TagName("td"));
        int j = 2;
        if (tdElements[j].Text == openDate && j < tdElements.Count)
        {
            j++;
            if (tdElements[j].Text == product)
            {
                j++;
                if (tdElements[j].Text == status)
                {
                    i = i + 1;
                    WaitforElementToBeClickable(By.XPath("//table/tbody/tr[" + i + "]/td[" + j + "]//a"));
                    IWebElement dataElement = DriverManager.driver.FindElement(By.XPath("//table/tbody/tr[" + i + "]/td[" + j + "]//a"));
                    JavaScriptEleClick(dataElement);
                    break;
                }
            }
        }
    }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题