【发布时间】:2018-11-03 12:18:06
【问题描述】:
我遇到了这样的问题,即使在 Internet Explorer 11 中给出了有效 ID,SendKeys() 也没有将值传递到正确的字段。如果我在 Chrome 66+ 浏览器中运行相同的脚本,它会按预期工作。为什么?
脚本:
// Address Line1
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_address1_text")).clear();
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_address1_text")).sendKeys(ADDRESS1);
Thread.sleep(1000)
// City
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_city_text")).clear()
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_city_text")).sendKeys(CITY_NAME)
Thread.sleep(1000)
// State
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_state_text")).clear()
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_state_text")).sendKeys(STATE_CODE)
Thread.sleep(1000)
// Postal code
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_postalCode_text")).clear()
driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_postalCode_text")).sendKeys(POSTAL_CODE)
Thread.sleep(1000)
上面提到的脚本取自更新屏幕。所以我正在清除现有内容并将值传递给相应的字段。
问题: 值不匹配,即 AddressLine1 值传递给 City 和 PostalCode 字段接收 FirstName 值(仅供参考:我没有在剧本中提到)
在 Chrome 浏览器 中执行相同的脚本时,它可以正常工作。为什么?
有人请给我解决方案吗?
谢谢
卡鲁纳加拉潘迪
【问题讨论】:
-
奇怪,我没有看到定位器标签已更改特定于浏览器,似乎您可能传递了错误的 id
-
嗨,我没有更改它在 Chrome 浏览器中完美运行的脚本。我也不知道怎么解决.. :(
-
好的,我会尝试找到解决方案
-
你能用你用来配置IEDriverServer的代码块更新问题吗?
标签: java selenium automation webdriver internet-explorer-11