SelectorsHub: How to Automate Shadow DOM & Nested Shadow DOM Elements in Selenium?

แชร์
ฝัง

ความคิดเห็น • 25

  • @SelectorsHub
    @SelectorsHub  2 ปีที่แล้ว

    Join my training to be expert in XPath, Selectors, WebElement, DOM, SelectorsHub & TestCase Studio. Registration Link-
    selectorshub.com/selectorshub-training/

  • @prakashth
    @prakashth 3 ปีที่แล้ว +1

    Thank you Sanjay, Excellent work & tool

  • @tulasiramsunkara
    @tulasiramsunkara 3 ปีที่แล้ว +1

    Excellent Sanjay....

  • @onkarmali-c7y
    @onkarmali-c7y 2 หลายเดือนก่อน

    Hello sanjay selctorhub can give script in format of document.querySelector('xyz').shadowRoot.querySelector('xyz')

  • @bscapco
    @bscapco ปีที่แล้ว

    Hello! im trying to use an if statement and isDisplayed command to execute a click. but the element is dynamic as it shows on one scenario and doesnt in another. so im hoping isDisplayed can help but before executing that method, the driver is getting error that the element is not found, what can i do here?

  • @jimmysaxblack
    @jimmysaxblack 3 ปีที่แล้ว +1

    thanks a lot for sharing this

  • @sresthamohanty439
    @sresthamohanty439 2 ปีที่แล้ว +1

    Hi it is returning host elements in search context not as webelement. What i need to do to get it as webelement

    • @SelectorsHub
      @SelectorsHub  2 ปีที่แล้ว

      From chrome 96 onwards, it returns SearchContext only. It doesn't support webelement. Please checkout this video to understand more about it- th-cam.com/video/IbjHhi7hcpI/w-d-xo.html

  • @snehabhat4446
    @snehabhat4446 2 ปีที่แล้ว +1

    Hi Sanjay, Could you teach how to insert shadow DOM elements in a list. This is required for my work. Please help. I am using JSPath to locate shadow DOM elements
    Regards
    Sneha

    • @SelectorsHub
      @SelectorsHub  2 ปีที่แล้ว

      This video is not there. But it should be simple, use findElements method.
      For ex-
      //This Element is inside single shadow DOM.
      String cssSelectorForHost = "#userName";
      Thread.sleep(1000);
      SearchContext shadow = driver.findElement(By.cssSelector("#userName")).getShadowRoot();
      Thread.sleep(1000);
      WebElement a = shadow.findElement(By.cssSelector("#kils"));
      List b = shadow.findElements(By.cssSelector("#kils"));

    • @snehabhat4446
      @snehabhat4446 2 ปีที่แล้ว

      @@SelectorsHub Hi Sanjay, thanks for the info. This video is helpful. In my case I have a field which has multiple values inside it. And I need to insert those values in a list.
      It shows its under 9 nested DOM in SelectorsHub. I am not supposed to paste the complete path here and the last section is as below.
      shadow8.findElement(By.cssSelector("div:nth-child(2)>div:nth-child(2)>div:nth-child(1)>span:nth-child(5)"));
      Here div:nth-child(1) is not constant. It identifies the first value and it changes to div:nth-child(2) when we locate 2nd value.
      Could you please help to place these values in a list?
      Regards
      Sneha

  • @lokeshsinha4777
    @lokeshsinha4777 3 ปีที่แล้ว +1

    Sanjay you are a gem. This tool is masterpiece. Thanks a lot.

  • @abuhussain3626
    @abuhussain3626 2 ปีที่แล้ว

    I need css selector for shadowroot elements.
    Can you please query one nested shadowroot element over css and apply some styles. Show whether it applies to that targetted shadowroot element or not?

  • @ganeshkannan627
    @ganeshkannan627 ปีที่แล้ว

    i could not see any selenium codes generated for shadow dom elements in my system

  • @rihaskh
    @rihaskh 2 ปีที่แล้ว

    Yes Sanjay ,but here Shadow Dom elements are in "open" so we can find the locators ...in my case shadow dom elements is in " User agent ".
    So how to find the xpath of elements which are under user agent (Shadow Dom)??

    • @SelectorsHub
      @SelectorsHub  2 ปีที่แล้ว +1

      Rihas, xpath doesn’t support shadow dom. When you inspected element what infor you got in SelectorsHub? You can join me on boot camp, there will discuss this.
      selectorshub.com/selectorshub-training/

  • @jimmysaxblack
    @jimmysaxblack 3 ปีที่แล้ว +1

    how can i get in touch with you ?

    • @SelectorsHub
      @SelectorsHub  3 ปีที่แล้ว

      Connect with me on slack. Link you can find on SelectorsHub footer.

  • @AkshayThosare
    @AkshayThosare 2 ปีที่แล้ว

    not able to find using plugin

    • @SelectorsHub
      @SelectorsHub  2 ปีที่แล้ว +1

      Where are you not able to find? Please share more details.

  • @elmariscal5394
    @elmariscal5394 3 ปีที่แล้ว

    Do you know the pursose of why dev team uses shadow dom?thanks

  • @karlervincompuesto7899
    @karlervincompuesto7899 2 ปีที่แล้ว

    If i am using Cypress.. how can I used it?

    • @SelectorsHub
      @SelectorsHub  2 ปีที่แล้ว

      Please checkout this tutorial-
      th-cam.com/video/vtS6bifPAj4/w-d-xo.html

  • @vladimirvilcacortez6674
    @vladimirvilcacortez6674 2 ปีที่แล้ว

    help, I get this bug "Exception in thread "main" java.lang.ClassCastException: class org.openqa.selenium.remote.ShadowRoot cannot be cast to class org.openqa.selenium.WebElement (org.openqa.selenium.remote.ShadowRoot and org.openqa.selenium.WebElement are in unnamed module of loader 'app')"

  • @snehabhat4446
    @snehabhat4446 ปีที่แล้ว

    Hi Sanjay, Could you teach how to insert shadow DOM elements in a list?
    Below is the JSPath value of the element and we have list of similar elements in multiple rows in a table with incremental value such as xyz-data-table-row:nth-child(8), xyz-data-table-row:nth-child(9) etc.
    **NOTE: Entire JSPath (below mentioned )is same for the next element in the next row, only the value increments
    Could you please help me. I really need this for my work.
    Below is the JSPath of the first element in the table row.
    document.querySelector("body > xyz-app").shadowRoot.querySelector("#searchResults").shadowRoot.querySelector("xyz-page > div.content > xyz-results-view").shadowRoot.querySelector("#results").shadowRoot.querySelector("#results").shadowRoot.querySelector("#container > xyz-search_pp-search-results").shadowRoot.querySelector("xyz-results > xyz-data-table > xyz-data-table-row:nth-child(7) > xyz-data-table-checkbox").shadowRoot.querySelector("xyz-checkmark").shadowRoot.querySelector("iron-icon")