Skip to main content
Tweeted twitter.com/StackSQA/status/1283280150281494528
Bumped by Community user
added 52 characters in body
Source Link
PDHide
  • 11.1k
  • 2
  • 16
  • 43

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
options.AddAdditionalCapability("disable-popup-blocking", true);
options.EnablePersistentHover = true;
options.EnsureCleanSession = true;
options.EnableNativeEvents = false;
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Top;
options.IgnoreZoomLevel = true;
options.EnsureCleanSession = true;
options.AddAdditionalCapability("IE_ENSURE_CLEAN_SESSION", true);
options.AddAdditionalCapability("JAVASCRIPT_ENABLED", true);

InternetExplorerOptions options = new InternetExplorerOptions();  
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;  
options.RequireWindowFocus = true;  
options.AddAdditionalCapability("disable-popup-blocking", true);  
options.EnablePersistentHover = true;  
options.EnsureCleanSession = true;  
options.EnableNativeEvents = false;  
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;  
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Top;  
options.IgnoreZoomLevel = true;  
options.EnsureCleanSession = true;  
options.AddAdditionalCapability("IE_ENSURE_CLEAN_SESSION", true);  
options.AddAdditionalCapability("JAVASCRIPT_ENABLED", true);
IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("javascript:window.scrollBy(1119,3)"); // this is the coordinates of the element once scrolled into view IJavaScriptExecutor clicker = (IJavaScriptExecutor)driver; clicker.ExecuteScript("arguments[0].click();", btnsearch); driver.ExecuteJavaScript("arguments[0].click();", btnsearch); Actions act = new Actions(driver); act.MoveToElement(btnsearch).SendKeys(Keys.Enter).Build().Perform(); btnsearch.Click();
<code>
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("javascript:window.scrollBy(1119,3)"); // this is the coordinates of the element once scrolled into view  
IJavaScriptExecutor clicker = (IJavaScriptExecutor)driver;
clicker.ExecuteScript("arguments[0].click();", btnsearch);
driver.ExecuteJavaScript<object>("arguments[0].click();", btnsearch);  
Actions act = new Actions(driver);
act.MoveToElement(btnsearch).SendKeys(Keys.Enter).Build().Perform();  
btnsearch.Click();
</code>

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
options.AddAdditionalCapability("disable-popup-blocking", true);
options.EnablePersistentHover = true;
options.EnsureCleanSession = true;
options.EnableNativeEvents = false;
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Top;
options.IgnoreZoomLevel = true;
options.EnsureCleanSession = true;
options.AddAdditionalCapability("IE_ENSURE_CLEAN_SESSION", true);
options.AddAdditionalCapability("JAVASCRIPT_ENABLED", true);

IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("javascript:window.scrollBy(1119,3)"); // this is the coordinates of the element once scrolled into view IJavaScriptExecutor clicker = (IJavaScriptExecutor)driver; clicker.ExecuteScript("arguments[0].click();", btnsearch); driver.ExecuteJavaScript("arguments[0].click();", btnsearch); Actions act = new Actions(driver); act.MoveToElement(btnsearch).SendKeys(Keys.Enter).Build().Perform(); btnsearch.Click();
InternetExplorerOptions options = new InternetExplorerOptions();  
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;  
options.RequireWindowFocus = true;  
options.AddAdditionalCapability("disable-popup-blocking", true);  
options.EnablePersistentHover = true;  
options.EnsureCleanSession = true;  
options.EnableNativeEvents = false;  
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;  
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Top;  
options.IgnoreZoomLevel = true;  
options.EnsureCleanSession = true;  
options.AddAdditionalCapability("IE_ENSURE_CLEAN_SESSION", true);  
options.AddAdditionalCapability("JAVASCRIPT_ENABLED", true);
<code>
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("javascript:window.scrollBy(1119,3)"); // this is the coordinates of the element once scrolled into view  
IJavaScriptExecutor clicker = (IJavaScriptExecutor)driver;
clicker.ExecuteScript("arguments[0].click();", btnsearch);
driver.ExecuteJavaScript<object>("arguments[0].click();", btnsearch);  
Actions act = new Actions(driver);
act.MoveToElement(btnsearch).SendKeys(Keys.Enter).Build().Perform();  
btnsearch.Click();
</code>
Source Link

Selenium Click not working on IE11 using c#

Local Machine: Dell Latitude (i7-8650U CPU @ 1.90GHz 2.11 GHz) with 16.0 GB RAM
Operating System: Windows 10 Pro (64-bit) v1909
Display Scale and Layout: 100%

Running on Visual Studio 2017 (v 15.9.21)
.NET Framework (v 4.8.03752)
Selenium NuGet package Selenium.WebDriver.IEDriver (v3.150.1) by jsakamoto

Internet Explorer 11, (v 11.836.18362.0) with Zoom = 100%

InternetExplorerOptions options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
options.RequireWindowFocus = true;
options.AddAdditionalCapability("disable-popup-blocking", true);
options.EnablePersistentHover = true;
options.EnsureCleanSession = true;
options.EnableNativeEvents = false;
options.UnhandledPromptBehavior = UnhandledPromptBehavior.Accept;
options.ElementScrollBehavior = InternetExplorerElementScrollBehavior.Top;
options.IgnoreZoomLevel = true;
options.EnsureCleanSession = true;
options.AddAdditionalCapability("IE_ENSURE_CLEAN_SESSION", true);
options.AddAdditionalCapability("JAVASCRIPT_ENABLED", true);

Classic ASP page
Element is an input element of type="button"

I instantiate the element using a factory, and the element variable name is "btnsearch" I then execute the following code and NONE of these approaches will trigger a Click event. Each approach appears to click the element, but the element doesn't seem to fire the click event through Selenium. If I physically click on the button, it fires the click event.

IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("javascript:window.scrollBy(1119,3)"); // this is the coordinates of the element once scrolled into view IJavaScriptExecutor clicker = (IJavaScriptExecutor)driver; clicker.ExecuteScript("arguments[0].click();", btnsearch); driver.ExecuteJavaScript("arguments[0].click();", btnsearch); Actions act = new Actions(driver); act.MoveToElement(btnsearch).SendKeys(Keys.Enter).Build().Perform(); btnsearch.Click();

I've even tried to add an event listener to send a keyup event (Enter key) and Selenium throws an exception "Object doesn't support property or method 'addEventListener'"

HELP PLEASE!!! I have searched extensively for a way to make this happen and have experimented with multiple variations of the IE Options (on and off) along with different coded methods. Unfortunately, the developers that work on this legacy app are unlikely to make any substantive updates until this app becomes sunsetted. What other things can I try? I'd even take a complicated workaround just to make my automation work until the sunset actually occurs.