简体   繁体   中英

How to edit #shadow-root (user-agent) value in selenium with Python

My working environment is Python, Chrome, Selenium

I want to edit shadow-root (user-agent)'s value

    <div class="divclass">
      <input type="tel" id="mytel" name="telamount" data-wheel-step="100" class="oneclass" value="1">
        #shadow-root (user-agent)
          <div>1</div>
      </input>
</div>

If I'm using js's .getAttribute() , with input's id "mytel" that can attach the value 1, but it isn't attach shadow-root.

I want change <div> 's 1

I've been looking hard, but I don't even know if this is possible.

The value is within a #shadow-root (user-agent)

@dylanb in one of his comment clearly mentions the following:

If web components are created with the closed flag and these web components create interactive elements within their shadow DOM, it is not possible for auditing tools to check for the validity of that markup.

Further he also adds:

In addition, if a user of that component wishes to use automation tools like Selenium to automate the testing of that component, it is not possible to interact with the shadow DOM components.

The two possible solutions he spoke about are:

  • Remove this closed flag altogether
  • Expose the composed tree through a set of APIs that will allow automation and auditing to occur regardless of the closed/open mode. This should include an API to efficiently discover and return the DOM nodes that have a shadow root and should allow for querySelector* to operate within this composed tree.

But these steps are beyond the scope of Selenium.


Reference

You can find a relevant detailed discussion in:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM