如何使用selenium webdriver点击子菜单?

问题描述 投票:0回答:2

我必须点击“Candidate”子菜单,下面给出了相同的HTML

enter image description here

selenium-webdriver
2个回答
0
投票

c#中的一个例子如下:

driver.FindElement(By.XPath("//a[contains(@title, 'Candidate')]")).Click();

或者:

driver.FindElement(By.XPath("//a[contains(@href, '/candidate/search')]")).Click();

0
投票

亲爱的朋友,你可以采取以下的答案..其中的链接是www.amazon.in

   for(int i=1;i<=webTableRows.size();i+=2) {
        ArrayList <WebElement> webTableCols = (ArrayList<WebElement>)driver.findElements(By.xpath(".//*[@id='navFooter']/div[4]/table/tbody/tr["+i+"]/td"));
        System.out.println(webTableCols.size());
        for (int j=1;j<=webTableCols.size();j+=2) {
                if(i==3 && j==11) {
                    break;
                }
                WebElement strElement = driver.findElement(By.xpath(".//*[@id='navFooter']/div[4]/table/tbody/tr["+i+"]/td["+j+"]/a"));


                if(strElement.isDisplayed()) {

                    String strData = strElement.getText();
                    String[] newString = strData.split("\n");

                    System.out.print(newString[0]);
        }
© www.soinside.com 2019 - 2024. All rights reserved.