0

I'm trying to find a dynamic Web Element, so I can't find by ID or Xpath. I tried to found using "Tab" or using another keyboard command unsuccessfully.

On another page with this same condition I tried the following code and it work:

            public void SeachApp() {
            WebElement elem = driver.findElement(By.xpath("//*[contains(text(),'BaseAloca')]"));
                int width = ((WebElement) elem).getSize().getWidth();

                Actions act = new Actions(driver);
                act.moveToElement((WebElement) elem).moveByOffset((width/2)-2 0).click().perform();
        }

But on this new page is not working. This is the page:

enter image description here

HTML code Page 1:

<circle class="bubble" r="48" style="filter: url(&quot;https://us.qlikcloud.com/node/i-0fc3fc8cc088b4fb7/sense/app/b5573a15-e951-45b5-81ed-92ef95c916bc/datamanager/datamanager#bubble-drop-shadow&quot;); fill: url(&quot;https://us.qlikcloud.com/node/i-0fc3fc8cc088b4fb7/sense/app/b5573a15-e951-45b5-81ed-92ef95c916bc/datamanager/datamanager#bubble-fill&quot;);"></circle>

<text class="label" y="5" text-anchor="middle">BaseAloca</text>

There is another page that I can do this click: enter image description here

HTML code Page 2:

<iframe id="appFrame" ng-mouseenter="refreshCookies()" tenantid="5b5f0e2aa543a3be1cf15913" ng-src="/node/i-01bc83ae6124b5e05/sense/app/22110b43-a3d3-4d3e-8d45-c944f216fbab?instance=qlik-i-01bc83ae6124b5e05" src="/node/i-01bc83ae6124b5e05/sense/app/22110b43-a3d3-4d3e-8d45-c944f216fbab?instance=qlik-i-01bc83ae6124b5e05"></iframe>

<div class="table-inner" ng-class="{ 'selected': isTableSelected(), 'nointeraction':!enableSelection() }" ng-click="selectTable($event)" ng-dblclick="editObject($event)" ng-disabled="true" aria-disabled="true" disabled="disabled">
    <div class="icon lui-icon lui-icon--table" ng-class="{ 'pending-delete': isTableDeleted() }"></div>
    <!-- ngIf: canSplit -->
    <!-- ngIf: showSelectionState  -->
    <div class="table-actions" ng-class="{ 'pending-delete': isTableDeleted() }">
        <!-- ngIf: tableObj.sourceType === 'ScriptTable' -->

        <!-- ngIf: canSplit && !disableButtons && !splitIndividualTablesFeature -->
        <!-- ngIf: canSplit && !disableButtons && splitIndividualTablesFeature -->
        <!-- ngIf: tableObj.isFiltered && !disableButtons && !canSplit -->
        <!-- ngIf: canEdit && !disableButtons --><div class="action-icon lui-icon lui-icon--edit qui-btn-icn lui-btn-div ng-scope" q-title-translation="DataManager.Overview.Tooltip.Edit" ng-if="canEdit &amp;&amp; !disableButtons" ng-click="onTableEditClick($event)" title="Edit this table"></div><!-- end ngIf: canEdit && !disableButtons -->
        <!-- ngIf: canDelete && !disableButtons --><div class="action-icon lui-icon lui-icon--bin qui-btn-icn lui-btn-div ng-scope" q-title-translation="DataManager.Overview.Tooltip.Delete" ng-if="canDelete &amp;&amp; !disableButtons" ng-click="onTableDeleteClick($event)" title="Delete this table"></div><!-- end ngIf: canDelete && !disableButtons -->

    </div>
    <div class="table-information" ng-class="{ 'pending-delete': isTableDeleted() }">
        <div class="table-name ng-binding" ng-bind="tableObj.name" title="BaseAloca">BaseAloca</div>
        <!-- ngIf: tableObj.hint -->
        <div class="table-subtitle ng-binding" ng-bind="tableObj.sourceName" title="Proj.xlsm">Proj.xlsm</div>
    </div>
    <!-- ngIf: !pendingAction --><div class="status-bar ng-scope" ng-class="pendingAction.class" ng-if="!pendingAction">
        <div class="left-side">
            <!-- ngIf: tableObj.fields.length > 0 --><div class="fields ng-binding ng-scope" ng-if="tableObj.fields.length > 0">Fields: 40</div><!-- end ngIf: tableObj.fields.length > 0 -->
            <!-- ngIf: hasGeoField() -->
            <div class="status-icon" ng-class="{true: 'lui-icon lui-icon--script'}[tableObj.sourceType === 'ScriptTable']" q-title-translation="DataManager.Overview.SynchronizeTooltip" title="Click to open the synchronization option for scripted tables"></div>
            <!-- ngIf: tableObj.isFiltered -->
        </div>
    </div><!-- end ngIf: !pendingAction -->
    <!-- ngIf: pendingAction -->

</div>

Can you help me?

Cleicy Guião
  • 111
  • 1
  • 20
  • 2
    Share HTML for the same. Also try `"//*[contains(.,'BaseAloca')]"` – Andersson Aug 29 '18 at 17:36
  • 1
    The `` tag is from the _svg_ namespace. Check this discussion how to deal with _svg_ elements https://stackoverflow.com/questions/41829000/selenium-webdriver-java-how-to-click-on-elements-within-an-svg-using-xpath – undetected Selenium Aug 29 '18 at 18:22
  • 2
    The HTML you posted doesn't contain the text 'BaseAloca'. Where is the HTML with that text? Maybe post more of the surrounding HTML. Is this area inside an IFRAME? – JeffC Aug 29 '18 at 19:38
  • Now is the full code! Thanks – Cleicy Guião Aug 30 '18 at 12:09

1 Answers1

1

You can try following code to identify this particular "bubble" class element:

WebElement elem = driver.findElement(By.xpath("//*[name()='circle'][contains(@style,'https://us.qlikcloud.com/node/i-0fc3fc8cc088b4fb7/sense/app/b5573a15-e951-45b5-81ed-92ef95c916bc/datamanager/datamanager#bubble-drop-shadow')]"));

Update #1:

driver.switchTo().frame("appFrame");     //need to switch to this frame before identifying elements present on frame with id "appFrame"
WebElement elem = driver.findElement(By.xpath("//div[@class='table-information']/div[@title='BaseAloca']"));
Kushal Bhalaik
  • 3,349
  • 5
  • 23
  • 46
  • It doesn't work =( o such element: Unable to locate element: {"method":"xpath","selector":"//*[name()='circle'][contains(@style,'https://us.qlikcloud.com/node/i-0fc3fc8cc088b4fb7/sense/app/b5573a15-e951-45b5-81ed-92ef95c916bc/datamanager/datamanager#bubble-drop-shadow')]"} – Cleicy Guião Aug 30 '18 at 12:19
  • 1
    I don't see any tag inside your HTML code Page 2 – Kushal Bhalaik Aug 31 '18 at 11:28
  • I have two ways to update these tables, the first one is on page 1 (Circle), and the second is page 2 (Table object). If I could click on one of these two ways is fine! =). – Cleicy Guião Aug 31 '18 at 11:38
  • what error do you get when you try update#1, also please check if your table is inside an iframe or not – Kushal Bhalaik Aug 31 '18 at 11:40
  • Error: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@class='table-information']/div[@title='BaseAloca']"} I updated the HTML page 2, I found this iFrame with all this tables inside. =) – Cleicy Guião Aug 31 '18 at 11:52
  • 1
    @CleicyGuiãoyou need to first switch to "appFrame" before interacting with elements on the frame using `driver.switchTo()`, check my updated #1 section. – Kushal Bhalaik Aug 31 '18 at 15:55