mercredi 24 janvier 2018

How to locate Polymer 2 elements to use with Selenium?

I have reviewing some answers at this site for location of Polymer elements and still wasn't able to find a solution for this blocking issue.

This is the Html source for a Login Page:

<paper-input-container id="container" class="style-scope paper-input x-scope paper-input-container-1" dir="null">


<div class="floated-label-placeholder style-scope paper-input-container" aria-hidden="true" hidden="">&nbsp;</div>

<div class="input-wrapper style-scope paper-input-container">
  <span class="prefix style-scope paper-input-container"></span>

  <div id="labelAndInputContainer" class="input-content style-scope paper-input-container">
    <label aria-hidden="true" for="input" slot="label" class="style-scope paper-input"

id="paper-input-label-1">Username

  <input id="nativeInput" class="style-scope paper-input" required="" autocomplete="on" placeholder="" autocapitalize="none"

autocorrect="off" aria-describedby="paper-input-add-on-3" aria-labelledby="paper-input-label-1" pattern="[A-Za-z0-9._%+-]+@[A-za-z0-9.-]+.[A-Za-z]{2,10}$">

  <span class="suffix style-scope paper-input-container"></span>
</div>

<div class="underline style-scope paper-input-container">
  <div class="unfocused-line style-scope paper-input-container"></div>
  <div class="focused-line style-scope paper-input-container"></div>
</div>

<div class="add-on-content style-scope paper-input-container">
  <paper-input-error aria-live="assertive" slot="add-on" class="style-scope paper-input x-scope paper-input-error-1"

id="paper-input-add-on-3">

Please enter valid email id   </paper-input-error>
</div>   </paper-input-container>   </paper-input>

We are using Selenium Webdriver with Page Factory design pattern, I have this function at BasePage class:

public IWebElement ExpandShadowRoot(IWebElement shadowRootElement) { IWebElement shdowTreeParent = (IWebElement)((IJavaScriptExecutor)_driver) .ExecuteScript("return arguments[0].shadowRoot", shadowRootElement); return shdowTreeParent; }

Thanks in advance for your help regarding this issue.

Aucun commentaire:

Enregistrer un commentaire