简体   繁体   中英

How can i get #shadow-root (user-agent) Cypress JS

If is any way how I can get to the #shadow-root (user-agent) element???

Hi I need to change the value in div, I tried to change the input and it doesn't help me

在此处输入图像描述

No, the (user-agent) tag tells you that the browser is implementing the shadow elements. In this case, they are read-only.

Nor should you attempt to modify it directly in a test, since it is internal implementation. You should interact with the <input> element itself, although it has a readonly attribute so you would have to force it.

cy.get('input[id="PersonalDetails/tel"]')
  .type('123', {force:true})
  .trigger('change')
  .shadow()
  .find('div')
  .should('have.text', '123')

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