Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SendKeys不填充Internet Explorer中各个组件中的值,但它在Chrome中填充_Java_Selenium_Automation_Webdriver_Internet Explorer 11 - Fatal编程技术网

Java SendKeys不填充Internet Explorer中各个组件中的值,但它在Chrome中填充

Java SendKeys不填充Internet Explorer中各个组件中的值,但它在Chrome中填充,java,selenium,automation,webdriver,internet-explorer-11,Java,Selenium,Automation,Webdriver,Internet Explorer 11,我面临这样一个问题,SendKeys()即使在InternetExplorer11中提供了有效ID,也没有将值传递到正确的字段。如果我在Chrome 66+浏览器中运行相同的脚本,它将按预期工作。为什么? 脚本: // Address Line1 driver.findElement(By.id("accountForm:accountTabSet:0:paCustForm_main_address1_text")).clear(); driver.findElement(By.id("acco

我面临这样一个问题,SendKeys()即使在InternetExplorer11中提供了有效ID,也没有将值传递到正确的字段。如果我在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)
上面提到的脚本取自更新屏幕。因此,我正在清除现有内容并将值传递给相应的字段

问题: 值不匹配,即地址行1值被传递到城市后代码字段接收名字值(仅供参考:我在脚本中没有提到)

在Chrome浏览器中执行相同的脚本时,它可以正常工作。为什么?

有人能给我解决这个问题的办法吗

已编辑:附加屏幕截图

谢谢

卡鲁纳加拉·潘迪(Karunagara Pandi)

这个问题经常发生。可能是由于错误的驱动程序,错误版本的驱动程序,以及IE实际上是一个灾难性的浏览器。 您可能找到的元素是正确的(如果它适用于Chrome),但sendKeys()方法在IE上无法正常工作。如果它有问题,Safari上也会出现此问题

尝试以下方法之一,可能会有所帮助:

对于64位Web驱动程序: 1.信息抽取 2.转到Internet选项→ 先进的→ 安全 3.检查☑ 为增强保护模式启用64位进程单击 4.申请并确认

对于32位Web驱动程序: 1.信息抽取 2.转到Internet选项→ 先进的→ 安全 3.取消勾选☐ 为增强保护模式启用64位进程 4.单击应用并确定

而且:

Internet选项->安全->选中所有区域的“启用保护模式” 转到高级->安全->选中“启用增强保护模式”

在代码中,请尝试以下操作:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
...
capabilities.setCapability("requireWindowFocus", true);
WebDriver driver = new InternetExplorerDriver(capabilities);
试试这个,但对我来说,这只适用于IE的几个版本:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('ID').value='VALUE';");

这个问题往往会发生。可能是由于错误的驱动程序,错误版本的驱动程序,以及IE实际上是一个灾难性的浏览器。 您可能找到的元素是正确的(如果它适用于Chrome),但sendKeys()方法在IE上无法正常工作。如果它有问题,Safari上也会出现此问题

尝试以下方法之一,可能会有所帮助:

对于64位Web驱动程序: 1.信息抽取 2.转到Internet选项→ 先进的→ 安全 3.检查☑ 为增强保护模式启用64位进程单击 4.申请并确认

对于32位Web驱动程序: 1.信息抽取 2.转到Internet选项→ 先进的→ 安全 3.取消勾选☐ 为增强保护模式启用64位进程 4.单击应用并确定

而且:

Internet选项->安全->选中所有区域的“启用保护模式” 转到高级->安全->选中“启用增强保护模式”

在代码中,请尝试以下操作:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
...
capabilities.setCapability("requireWindowFocus", true);
WebDriver driver = new InternetExplorerDriver(capabilities);
试试这个,但对我来说,这只适用于IE的几个版本:

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('ID').value='VALUE';");

我在Windows 10 64位操作系统上有IE11 32位浏览器和32位IE驱动程序服务器

我可以使用sendkeys在编辑字段中输入文本,但之后它会被删除

//WebElement defect=webControls.getDriver().findElement(By.id(“oneWayFlight_fromLocation”); //((JavascriptExecutor)webControls.getDriver()).executeScript(“document.getElementById('oneWayFlight_fromLocation')。value='JFK'); //((JavascriptExecutor)webControls.getDriver()).executeScript(“参数[0].value='JFK';”,离开); ((JavascriptExecutor)WebControl.getDriver()).executeScript(String.format(“document.getElementById('oneWayFlight_fromLocation'))。value='JFK';,“JFK”)

输入JFK,然后删除:


在Windows 10 64位操作系统上,我有IE11 32位浏览器和32位IE驱动程序服务器

我可以使用sendkeys在编辑字段中输入文本,但之后它会被删除

//WebElement defect=webControls.getDriver().findElement(By.id(“oneWayFlight_fromLocation”); //((JavascriptExecutor)webControls.getDriver()).executeScript(“document.getElementById('oneWayFlight_fromLocation')。value='JFK'); //((JavascriptExecutor)webControls.getDriver()).executeScript(“参数[0].value='JFK';”,离开); ((JavascriptExecutor)WebControl.getDriver()).executeScript(String.format(“document.getElementById('oneWayFlight_fromLocation'))。value='JFK';,“JFK”)

输入JFK,然后删除:


奇怪的是,我没有看到定位器标签因浏览器而异,似乎可能是您传递了错误的idHi,我没有更改脚本,它在Chrome浏览器中工作得很好。我也不知道如何解决这个问题(好的,我会尝试找到解决方案。你能用你用来配置IEDriverServer的代码块更新这个问题吗?奇怪的是,我看不到定位器标记是针对浏览器而更改的,似乎可能你传递了错误的idHi,我没有更改脚本,它在Chrome浏览器中工作得很好。我也不知道如何解决这个问题。)我相信(好的,我会尝试找到解决方案。你能用你用来配置IEDriverServer的代码块更新这个问题吗?回答得很好!!!但是如果选中了
启用增强保护模式
,你可以通过忽略安全域来避免添加
引入片状。准备好@JimEvans!回答得很好!!!但是如果
>启用增强的保护模式
已选中。您可以通过忽略安全域来避免添加
引入片状。为@JimEvans眩光做好准备