首页 > 解决方案 > 在硒中寻找伪元素

问题描述

我试图找到这个元素(下面的屏幕截图)我正在使用 Java,我尝试使用 cssSelector 和 xpath 都没有工作。

        Technology.click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id=\"paletteItem:_8827283_1\"]/a/span")));
    WebElement VS = driver.findElement(By.xpath("//*[@id=\"paletteItem:_8827283_1\"]/a/span"));
    VS.click(); // all of the above works correctly, but after this point it keeps waiting and then erroring.
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#main-content > header > div > h1")));
    System.out.println("Found");
    JavascriptExecutor js = (JavascriptExecutor) driver;
    js.executeScript("document.querySelector(\"#session-0c5d29dffcf04299a02e217d457f7718 > div.item-list__item-details.click()");

HTML:

<div class="item-list__item-wrapper ng-isolate-scope" bb-session-list-item-content="session" tooltip-position="tooltipPosition" expand="sessionListItem.toggleExpand()" is-expanded="sessionListItem.isExpanded()" is-admin-view="isAdminView" can-edit="sessionListItem.canEdit()" can-show-options="sessionListItem.canShowOptions()" can-launch="sessionListItem.canLaunch()" can-launch-phone="sessionListItem.canLaunchPhone()" can-delete="sessionListItem.canDelete()" can-show-reports="sessionListItem.canShowReports()" can-copy-guest-link="sessionListItem.canCopyGuestLink()"><button class="item-list__item session-list-item-content item-list__item--active" id="session-a07f7478cf154c6ea4e9a56e5f1f1bca" aria-label="Show occurrences for session: الإسبوع الثالث_الطرقان" aria-describedby="session-a07f7478cf154c6ea4e9a56e5f1f1bca-details" ng-attr-aria-expanded="{{session.hasOccurrences ? (isExpanded ? 'true' : 'false') : undefined }}" ng-click="sessionListItemContent.sessionClicked()" ng-class="{'item-list__item--active': canLaunch}" aria-expanded="true">

截图: 网站图片 ,元素代码

标签: javaseleniumwebdriver

解决方案


推荐阅读