Click Record Button at about:tracing through Selenium

I am trying to click the Record button through Selenium in Google Chrome. However I am not able to. Element is not found. I have tried using id and xpath. None of them worked.

WebElement record = driver.findElement(By.id("record-button")); record.click();

The HTML code is

<template id="profiling-view-template">
  <tr-ui-b-info-bar-group></tr-ui-b-info-bar-group>
  <x-timeline-view-buttons>
    <button id="record-button">Record</button>
    <button id="save-button">Save</button>
    <button id="load-button">Load</button>
  </x-timeline-view-buttons>
  <tr-ui-timeline-view>
    <track-view-container id="track_view_container"></track-view-container>
  </tr-ui-timeline-view>
</template>

Any lead will be appreciated.

1 answer

  • answered 2018-08-15 15:05 getThingsDone

    I am able to access that object by this

    WebElement root1 = driver.findElement(By.tagName("tr-ui-timeline-view")); WebElement shadowRoot1 = expandRootElement(root1); WebElement record1 = shadowRoot1.findElement(By.id("record-button")); record1.click();

    public WebElement expandRootElement(WebElement element) { WebElement ele = (WebElement) ((JavascriptExecutor) driver).executeScript("return arguments[0].shadowRoot", element); return ele; }