2

CSS で定義されているが html タグの一部ではない背景画像をクリックする方法はありますか? @class=hitLocation を含む div タグをクリックする必要があります。

<ul id="uxFolderTree_uxFolderTree_template_TreeRootElement" class="ui-tree-root">
<li class="-ui-tree-branch -ui-tree-folder -ui-tree-type-root collapsible" data--selectionmode="None" data-level="0" data-path="0" data-rootid="0" data-parentid="0" data-id="0">
  <div class="hitLocation">

CSSは

.ui-tree .ui-tree-branch.collapsible > .hitLocation {
background-image: url("/WorkArea/FrameworkUI/images/icons/plus.png");
background-position: 0 center;
cursor: pointer;
4

1 に答える 1

2

直接ではありません。

次のいずれかを実行できます。

  1. hitLocation要素をクリックするだけです。WebDriver は暗黙的に要素の中心をクリックするので、それで十分かもしれません。

  2. Advanced Interactions API を使用して、クリックする要素内の場所を指定します。

    たとえば、これは要素[1,1]の左上隅から数えて位置をクリックします。hitLocation

    WebElement hitLocation = driver.findElement(By.className("hitLocation"));
    new Actions(driver)
        .moveToElement(hitLocation, 1, 1)
        .click()
        .perform();
    
于 2013-09-03T21:12:05.743 に答える