简体   繁体   中英

How to click this row in selenium java?

During my manual execution, I was able to select the row of "HTTP.BROWSER" by a single click.

Here is a screenshot of the web page:

截图

The HTML

<ul>
    <li ng-repeat="d in $ctrl.pagedData track by $index" ng-class="[$ctrl.styles.circular, d.selected ? $ctrl.styles.selected : '']" ng-click="$ctrl.select($index)" class="ng-scope appSignatureModal__circular--Ny5Ib" style="">
        <div class="ellipsis appSignatureModal__modal-name-box--BiaO-" ng-class="$ctrl.styles.modalNameBox">
            <span class="app_icon app15893" ng-class="'app' + d.id" style=""></span>
            &nbsp;
            <span class="ellipsis ng-binding" ng-attr-title="{{d.name}}" title="HTTP.BROWSER">HTTP.BROWSER</span>
        </div>
        <div .../>
        <div .../>
    </li>
</ul>

When I try to simulate the same thing using Java/Selenium, the targeted row was not picked?

driver.findElement(By.xpath("//span[text() = 'HTTP.BROWSER']//ancestor::li")).click();

Any ideas what could be wrong? Thanks.

Can you try with Explicit wait

 WebDriverWait wait = new WebDriverWait(driver, 10);
 WebElement element = wait.until(ExpectedConditions.elementToBeClickable(Byxpath("//span[text() = 'HTTP.BROWSER']//ancestor::li")));

And also please check whether the element is in any frame or it is in the default content

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM