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; }
See also questions close to this topic
-
Progressive Web App, Add to home screen missing
I'm writing a PWA and using a self signed certificate. In order to test the service worker of the PWA I have to launch Chrome using the following flags
Chrome --user-data-dir=/tmp/foo --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://localhost:3000
This bypasses the issue with the certificate, however I do not see the add to homescreen option on Chrome when I open the browser like this. When I normally launch Chrome without these flags and naivgate to https://localhost:3000 then I see this option.
-
Sending message from website to Chrome Extension. How am i supposed to know the ID?
In the Chrome documentation, it states here that in your extension manifest, you should add the following:
{ "name": "My externally connectable extension", "externally_connectable": { // Extension and app IDs. If this field is not specified, no // extensions or apps can connect. "ids": [ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", ], "matches": [ "https://*.example.com/*", ], }, }
It then goes on to say that to send a message from your website to your Chrome Extension, you need to pass the Extension ID as the first parameter of the sendMessage function
// The ID of the extension we want to talk to. var editorExtensionId = "abcdefghijklmnoabcdefhijklmnoabc"; // Make a simple request: chrome.runtime.sendMessage(editorExtensionId, {openUrlInEditor: url}, function(response) { if (!response.success) handleError(url); });
Here's the issue. When a Chrome Extension is installed, it is given a random ID by Chrome. For example, in my development build, my PC install has a different ID to my macOS install. As such, the extension only works on the platform with the correct ID.
When I upload the extension to the Chrome store, how am I going to know the ID that it gets given in order to define that ID in my extensions manifest file and on my website?
-
How to copy content from website with javascript (chrome extension)
For example, I want to copy the word Bonjour to a variable from this google translate page. How can I do it with javascript in a chrome extension?
-
How to get jenkins test report link from surefire-reports testng-results.xml?
My current Jenkins runs multiple builds. Each build/run would create its own testng-results.xml (target/surefire-reports/testng-results.xml)
I check results from the HTML report available on the Jenkins job homepage (which would show the report only of the latest build/run).
How do I get the report of a previous build from the corresponding testng-results.xml because I want to dump the report links for every build by extracting them from the testng-results.xml
I couldn't find any entry in the testng-results.xml that points to the path/place where the corresponding test report for that run/build resides.
Anyway to get this?
-
Selenium Python: How to wait until an element finish changing the text before reading the value using?
I am trying to read the value of a text from a page using Selenium Python. The element is always visible and then goes invisible and then becomes visible and the text value changes rapidly until it reaches the final value. I think it is using some form of javascript to get the value before displaying the final value.
The page is https://www.junglescout.com/estimator/
I am trying to get the result of the estimate from the element js-magic-result.
I'm able to use Selenium to fill the three forms and click the 'calculates sales' button
I am using the chromedriver in python selenium to read the value.
all the tests gets me one of the intermediate values before it finishes loading.
I tried using the folling inplace of the browser2.implicitly_wait(5):
driver.implicitly_wait(5) wait = WebDriverWait(browser2,3) wait.until(EC.invisibility_of_element_located((By.CLASS_NAME,'js-magic-result'))) wait.until(EC.visibility_of_element_located((By.CLASS_NAME,'js-magic-result')))
Here is the full code I am using
browser2 = webdriver.Chrome(options=options,executable_path=driverPath) url = 'https://www.junglescout.com/estimator/' browser2.get(url) container = browser2.find_element_by_class_name('js-estimation-section') rankField = container.find_element_by_name('theRankInput') rankField.send_keys('345') # Click for storesList drop down storeGroup = container.find_element_by_class_name('js-est-stores-list-input') storeGroup.find_element_by_class_name('x-icon-caret-down').click() # Get Stores List items wait = WebDriverWait(browser2,3) stores = wait.until(EC.visibility_of_element_located((By.CLASS_NAME,'js-est-stores-list'))) stores.find_elements_by_tag_name('span')[0].click() # Wait for storesList is invisible wait.until(EC.invisibility_of_element_located((By.CLASS_NAME,'js-est-stores-list'))) # Click for Categories list drop down catGroup = container.find_element_by_class_name('js-est-categories-list-input') catGroup.find_element_by_tag_name('input').click() # Get Categories List items cats = wait.until(EC.visibility_of_element_located((By.CLASS_NAME,'js-est-categories-list'))) # Get Categories List items for cat in cats.find_elements_by_class_name('us-available'): if (cat.find_element_by_tag_name('span').text == 'Electronics'): cat.click() break # Wait for storesList is invisible wait.until(EC.invisibility_of_element_located((By.CLASS_NAME,'js-est-categories-list'))) # wait5 = WebDriverWait(browser2,3) submit = wait.until(EC.visibility_of_element_located((By.CLASS_NAME,'js-est-btn'))) submit.click() browser2.implicitly_wait(5) print(container.find_element_by_class_name('js-magic-result').text)
What I expect is to get the final value returned but what I get is one of the intermediate values from the element.
-
Build Error: Cannot find the class file for org.openqa.selenium.internal.Locatable
I'm using Selenium and Maven to build a project in Eclipse and I'm getting the build error: Cannot find the class file for org.openqa.selenium.internal.Locatable.
I'm using
Selenium-Server-Standalone 3.141.59
, which I've noticed has the Locatable class under...org.openqa.selenium.**interactions**.Locatable
instead of...
org.openqa.selenium.**internal**.Locatable.
Is this a different class altogether?
How do I get Eclipse to recognize that the class is there?
Please find followings are my relevant dependencies from my
Pom.xml
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>3.141.59</version> </dependency> <dependency> <groupId>com.codeborne</groupId> <artifactId>selenide</artifactId> <version>2.3</version> </dependency> <!-- https://mvnrepository.com/artifact/com.codeborne/phantomjsdriver --> <dependency> <groupId>com.codeborne</groupId> <artifactId>phantomjsdriver</artifactId> <version>1.3.0</version> </dependency> <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <!-- https://mvnrepository.com/artifact/log4j/log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
-
Find scrollable container of an element, including in shadow DOM
I'm looking for a generic solution to find the scrollable container of an element (I'd like to listen to the scroll event). The normal approach would be to traverse up in the DOM tree in check the parent elements until one of them is scrollable - here are some solutions like this. However this will fail if shadow DOM is also in the picture.
Here's an example structure:
<app-home> <ion-content> #shadow-root <div class="inner-scroll"> <slot> -> <my-element> (reveal) </slot> </div> <my-element>...</my-element> </ion-content> </app-home>
In the above example the scrollable element is
.inner-scroll
, which is inside the shadow dom ofion-content
. Sincemy-element
gets into the container through theslot
, traversing up the tree will never reach the scroll container (my-element
->ion-content
->app-home
).I found that
ion-content
has a getScrollElement method, which can be used in this specific case, however I'd like to know if there's a generic DOM based solution, since I'd like this to work regardless of the context.UPDATE:
To be more clear, I'd like
my-element
to be a standalone, reusable component, which can find it's scrolling container, no matter where it's placed. What I found, that the built inscrollIntoView
method works on the DOM element, and it scrolls the correct container, meaning that the browser somehow figures it out, but does not expose a method which returns the scroll container.Another idea was to listen to the scroll event on a higher level, without knowing the exact element, but this is not working either, because the scroll event does not propagate.
Any ideas?
-
Force focus event inside of a slot element
I'm trying to focus an element that's inside of a slot element that it's being used in a custom-element.
Inside of my custom element I query for the slot element, than I use the method .assignedElements, which is just one div, and then I query inside of that element to find the input that I want. After that i use the method .focus() to well, focus the input.. But that doesn't work.
Please let me know if anyone can help
I'm currently doing all that with Stencil component.
-
2 Shadow DOMs in one HTML page
I want to create/inject/set two Shadow DOMs in one Angular app with both CSS and js per each.
For the CSS - I know how to isolate it.
For the js - I have a collision with both variables and functions names.
Any idea?
index.html:
index2.html
- I make HTTP req in order to get the HTML files (with CSS and js).
- create a shadow dow per each
- append the file to the shadow dom
- and I'm getting this error
Error: