dom

How to read text that is under #shadow-root (user-agent)

早过忘川 提交于 2021-02-02 09:52:26
问题 I am using Selenium (Python) for automating a web page. I am trying to get text from an input field that is under #shadow-root (user-agent). Xpath I used: driver.find_element_by_xpath("**//*/p-calendar/span/input**").text is not returning anything. Attached the screenshot of my DOM element. Requirement: To get text from the shadow root : 01:01 回答1: As per @hayatoito 's (creator of Shadow DOM) comment: The original motivation of introducing a closed shadow tree is "Never allow an access to a

How to create radio buttons dynamically?

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-29 20:38:39
问题 i have a problem in creating radio buttons dynamically, i have a text box and a button, i asked the user to input a value in the text field then i retrieve the text box value and use it to create a radio button when he press a button, i tried this code in javaScript but it doesn't create a radio button on clicking the specified button: <script type="text/javascript" > function createRadioElement(value, checked) { var radioHtml = '<input type="radio" value="' + value + '"'; if ( checked ) {

How to add/remove class to specific anchor elements inside div?

别等时光非礼了梦想. 提交于 2021-01-29 18:07:46
问题 I have a DOM as shown below in which to add/remove class only after third anchor element (only 4th and 5th element). <div class="featured-block"> <a href="" class="featured-block__item cf"> <!-- 1st element --> </a> <a href="" class="featured-block__item cf"> <!-- 2nd element --> </a> <a href="" class="featured-block__item cf"> <!-- 3rd element --> </a> <a href="" class="featured-block__item cf"> <!-- Add/remove (4th element)--> </a> <a href="" class="featured-block__item cf"> <!-- Add/remove

Excel VBA and HTML DOM: Can't Click Tab

无人久伴 提交于 2021-01-29 17:29:00
问题 In Excel 2003 VBA, I'm trying to browse to this web page... https://www.google.com/finance?q=NYSE%3AWSO&fstype=ii&ei=cy30UrCEI8KKiALOPw ...and click these two tabs on it: - "Balance Sheet" - "Annual Data" Here's what the HTML for those tabs looks like: <a class=t><b class=t><b class=t>Balance Sheet</b></b></a> and <a id=annual class="id-annual nac">Annual Data</a> Finding Annual Data with getElementById, and clicking on it, worked fine. But Balance Sheet has no ID. Using getElementByClass

Performance of MutationObserver and ways to improve it

时光毁灭记忆、已成空白 提交于 2021-01-29 17:22:39
问题 I have some questions regarding MutationObserver and ways to improve it. From that answer: Use debounce or a similar technique e.g. accumulate mutations in an outer array and schedule a run via setTimeout / requestIdleCallback / requestAnimationFrame: const queue = []; const mo = new MutationObserver(mutations => { if (!queue.length) requestAnimationFrame(process); queue.push(mutations); }); function process() { for (const mutations of queue) { // .......... } queue.length = 0; } Is it

revise deeply nested JSON array in DOM

爱⌒轻易说出口 提交于 2021-01-29 12:21:51
问题 I have an HTML page that contains a stringified JSON object. The object has this structure: { "x":{ "key1":[], "key2":{}, "keyN":{}, "myKey":{ "randomID238492":{ "items":[ { "value":"zzzz" }, { "value":"aaaa" }, { ...} ] } } } } I want to replace this object with one in which the "items" array has been sorted. Here is what I will and won't know about the object: "myKey" and "items" will always be the relevant object keys "myKey" will contain only one random ID, and the "items" key will always

How do I see if a HTMLElement is of a viewable kind?

∥☆過路亽.° 提交于 2021-01-29 11:11:39
问题 If I list for example document.body.children I get some elements that can be shown on the screen (like <div> ) and some that can not be shown (like <script> ). Is there a (future) safe way to find out if an element can be shown on the screen? 回答1: All elements are "viewable": <style> * { display: block; } </style> <script> // even scripts </script> So either check if they are currently visible, by checking their computed style (I'll let you decide which properties you should check since even

AWS S3 bucket: CORS Configuration

梦想与她 提交于 2021-01-29 09:12:21
问题 I am trying to download an image from S3. But I got error CORS. What I have done: -Setup CORS configuration for S3 bucket: <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>POST</AllowedMethod> <AllowedMethod>PUT</AllowedMethod> <AllowedMethod>HEAD</AllowedMethod> <ExposeHeader>Accept-Ranges</ExposeHeader> <ExposeHeader>Content-Range<

Run DOM-based Javascript from command line

强颜欢笑 提交于 2021-01-29 08:16:08
问题 I have some Javascript that is interacting with the DOM from a website. document.location.href="https://www.example.com"; It works well from Chrome console, but I would like to run that code from the command line. How can I do it? NodeJS gives "document is not defined" error. 回答1: In order to use command line to inject Javascript code in a browser's DOM you actually need... a browser that runs Javascript code ad has a DOM . You can go with something like Selenium or rely on a bridged library

How to read XML node's value in InstallScript

牧云@^-^@ 提交于 2021-01-29 08:10:24
问题 I have following XML file. <Configuration> <Config1 connection="SQL">SampleData<Config1> </Configuration> I want to read the value "SampleData" of node Config1 in InstallScript function. I tried properties text, value, nodevalue. But none of it worked. I can read attribute connection's value. But how I can read node's value "SampleData"? 回答1: Help Documentation : Maybe try this help file documentation: Searching for XML Data Modifying XML Files Using XPath Expressions to Find XML Data in an