无法使用Selenium Java脚本在模式对话框中单击项目

问题描述 投票:-1回答:1

我的用户界面看起来像:

enter image description here

我的HTML看起来像

enter image description here

我无法使用Selenium Web驱动程序单击模式对话框中的项目。

我尝试过下面的代码

            List<WebElement> allBrancheRows=driver.findElements(By.xpath("table[@id='body_ucLookup1_grdData']tr"));

            for(int i=2;i<=allBrancheRows.size();i++)
            {
                WebElement BranchColumn=driver.findElement(By.xpath("table[@id='body_ucLookup1_grdData']tr["+i+"]td[3]"));
                if(BranchColumn.getText()=="NSW")
                {
                    JavascriptExecutor executor = (JavascriptExecutor)driver; 
                    executor.executeScript("arguments[0].click();", BranchColumn);
                    BranchColumn.click();
                    break;
                }
            }

i have tried using click() method as well before using JavaScript. Even this has not worked.
Please advise
java html selenium dom selenium-chromedriver
1个回答
0
投票

使用此xpath应该可以使用。

© www.soinside.com 2019 - 2024. All rights reserved.