【发布时间】:2018-01-23 21:11:01
【问题描述】:
我很难尝试使用 Java (Chrome) 在 Selenium WebDriver 上自动化三个具有相同输入 ID 的文本字段。以下是链接的网站信息。
抄送
<input
id="recurly-hosted-field-input"
type="tel"
pattern="[0-9]*"
spellcheck="false"
autocapitalize="none"
autocorrect="off"
class="recurly-hosted-field-input unknown"
placeholder="Credit Card Number"
title="Credit Card Number"
aria-required="true"
autocomplete="cc-number"
style="visibility: visible; color: rgb(51, 51, 51); font-family: Lato, sans-serif; font-feature-settings: normal; font-kerning: auto; font-size: 17px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-rendering: auto; text-shadow: none; text-transform: none;"
>
月份
<input
id="recurly-hosted-field-input"
type="tel"
pattern="[0-9]*"
spellcheck="false"
autocapitalize="none"
autocorrect="off"
class="recurly-hosted-field-input"
placeholder="Month (mm)"
title="Month (mm)"
maxlength="2"
aria-required="true"
autocomplete="cc-exp-month"
style="visibility: visible; color: rgb(51, 51, 51); font-family: Lato, sans-serif; font-feature-settings: normal; font-kerning: auto; font-size: 17px; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-rendering: auto; text-shadow: none; text-transform: none;"
>
这是我目前使用的格式。
driver.findElement(By.name("address1")).sendKeys("213 Ave");
driver.findElement(By.name("city")).sendKeys("New York");
【问题讨论】:
标签: java google-chrome selenium