I’ve inspected topic you sent. But It has a Javascript coding part. I know Selenium WebDriver and can locate via Javascript methods. But I couldn’t find anywhere to typing Javascript codes in KNIME.
As I see that KNIME is whole nodes.
Are there anywhere to type Java/Javascript codes in KNIME. (like an IDE)
Working with code, can be more simply for me.
You can use this node to execute JS which would usually run in the browser:
–Philipp
PS: As a side node (though not really relevant here): You can even execute Java code to access the full Selenium API. This is possible with the regular KNIME Java Snippet node. You can double click on a WebDriver or WebElement input in the node configuration, access their Java API just as in code using the Selenium library, and also return WebDriver resp. WebElement values. A simple example how to achieve this is available e.g. here:
I did what you adviced, thank you so much.
But I couldn’t locate shadow root element unfortunately
Find elements node is empty , I can’t locate “Sign-in” element to inside.
You’ll need to select the proper input argument (one of the entries with the mouse cursor icon, which represent WebElements) in the left column using a checkbox.
The selected items will be assigned to the arguments array in the JS code.
Hope this helps!
[edit] Also make sure to select the proper return type in the lower left corner - as you’re returning a WebElement chose this in the “Return type” menu.
You can do that using a Find Elements node, where you select the shadow DOM container - in your case this is obviously that ep-button element. Extract that element before the Execute JavaScript node and then select it as input.
Or instead, query for the shadow DOM container directly via JS code. Instead of …
Thank you - the DOM contains a nested shadow DOM, i.e. a shadow DOM within a shadow DOM. You’ll notice this if you carefully inspect the page structure from the button “upwards”.
Thus you’ll need to adapt the code to query twice into the shadow root:
const outerShadowDomContainer = document.querySelector('cars-auth-modal');
const innerShadowDomContainer = outerShadowDomContainer.shadowRoot.querySelector('ep-button[type="submit"]');
const submitButton = innerShadowDomContainer.shadowRoot.querySelector('button[type="submit"]');
// result will be the retrieved WebElement
return submitButton;
The shown error message is quite common with Selenium and I think we also discussed it here already in the forum once.
Essentially, make sure that the button which you’re trying to click is visible in the window: (a) browser window should be big enough or you need to scroll the button into the view, and/or (b) window should not be obscured by other overlays (such as cookie ), etc.