如何读取#shadow-root(用户代理)下的文本(Java-Selenium)
我试图找到属于#shadow-root(用户代理)的文本。我尝试了多种可以在这里找到的解决方案,但没有一个对我有用。尝试使用JavascriptExecutor。但这没有用。 我在 Java 语言中使用 selenium
要求:获取名字和姓氏并打印它。 名字:TEST 和姓氏:USER 位于 #shadow-root(用户代理)
下 下面是 HTML
<div class="form-group
required">
<label class="form-control-label" for="firstName">
First Name
</label>
<input type="text" class="form-control" id="firstName" data-missing-error="Please enter a value for Name" data-pattern-mismatch="Only letters, numbers, hyphens and apostrophes are allowed in someone's first name" data-range-error="Must be 30 characters or less." name="dwfrm_profile_customer_firstname" required="" aria-required="true" value="TEST" maxlength="30" pattern="^[a-zA-Z0-9-'][A-Za-z0-9-' ]*$">
#shadow-root (user-agent)
<div> TEST</div>
</input>
<div class="invalid-feedback"></div>
</div>
<div class="form-group
required">
<label class="form-control-label" for="lastName">
Last Name
</label>
<input type="text" class="form-control" id="lastName" data-missing-error="Please enter a value for Surname" data-pattern-mismatch="Only letters, numbers, hyphens and apostrophes are allowed in someone's last name" data-range-error="Must be 30 characters or less." name="dwfrm_profile_customer_lastname" required="" aria-required="true" value="USER" maxlength="30" pattern="^[a-zA-Z0-9-'][A-Za-z0-9-' ]*$">
#shadow-root (user-agent)
<div> TEST</div>[![enter image description here][1]][1]
</input>
<div class="invalid-feedback"></div>
</div>
I am trying to find a text which falls under #shadow-root (user-agent). I tried multiple solutions I could find here, but none of them worked for me.Tried to use JavascriptExecutor. But it didn't work.
I am using selenium in Java language
Requirement: get the First and Last name and print it.
First Name: TEST and Last Name: USER is coming under #shadow-root (user-agent)
Below is the HTML
<div class="form-group
required">
<label class="form-control-label" for="firstName">
First Name
</label>
<input type="text" class="form-control" id="firstName" data-missing-error="Please enter a value for Name" data-pattern-mismatch="Only letters, numbers, hyphens and apostrophes are allowed in someone's first name" data-range-error="Must be 30 characters or less." name="dwfrm_profile_customer_firstname" required="" aria-required="true" value="TEST" maxlength="30" pattern="^[a-zA-Z0-9-'][A-Za-z0-9-' ]*quot;>
#shadow-root (user-agent)
<div> TEST</div>
</input>
<div class="invalid-feedback"></div>
</div>
<div class="form-group
required">
<label class="form-control-label" for="lastName">
Last Name
</label>
<input type="text" class="form-control" id="lastName" data-missing-error="Please enter a value for Surname" data-pattern-mismatch="Only letters, numbers, hyphens and apostrophes are allowed in someone's last name" data-range-error="Must be 30 characters or less." name="dwfrm_profile_customer_lastname" required="" aria-required="true" value="USER" maxlength="30" pattern="^[a-zA-Z0-9-'][A-Za-z0-9-' ]*quot;>
#shadow-root (user-agent)
<div> TEST</div>[![enter image description here][1]][1]
</input>
<div class="invalid-feedback"></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Maven依赖添加
maven dependency to add