我已经在本网站上查看了一些关于聚合物元素位置的答案,但仍然无法找到解决此阻塞问题的方法。
这是登录页面的Html源:
<paper-input no-label-float="" id="username" label="Username" autocomplete="on" required="" class="form-control style-scope colt-login x-scope paper-input-1" pattern="[A-Za-z0-9._%+-]+@[A-za-z0-9.-]+\.[A-Za-z]{2,10}$" tabindex="0" aria-disabled="false">
<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=""> </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</label>
<iron-input id="input" slot="input" class="style-scope paper-input">
<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}$">
</iron-input>
</div>
<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>
我们正在使用Selenium Webdriver和Page Factory设计模式,我在BasePage类中有这个功能:
public IWebElement ExpandShadowRoot(IWebElement shadowRootElement)
{
IWebElement shdowTreeParent = (IWebElement)((IJavaScriptExecutor)_driver)
.ExecuteScript("return arguments[0].shadowRoot", shadowRootElement);
return shdowTreeParent;
}
提前感谢您就此问题提供的帮助。