Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium webdriver: IE 11 element.Click() doesnt work

I tried to find any solution but nothing is not helped me.

I have this element

<span data-lkd="GUI-411396" data-lkta="tc" data-lkda="title" class="panelbar_item" title="Hledat">Form</span>

In Selenium I find it with

IWebElement form = GetElementAndWaitForEnabled(By.CssSelector("span[data-lkd=\'GUI-411396\']"));

It's not problem to this part. But if try click on this element in IE11 nothing happend

find.Click()

I tried some solution like:

driver.SwitchTo().Window(driver.CurrentWindowHandle);
find.SendKeys(Keys.Enter);
find.Click();

But nothing happend. In Chrome and Firefox is normaly click on element. If I clik in other elements for example button it works on IE 11. But I need click on this element.

I'm using Selenium v2.46.0, IE 11 (x86, x64).

like image 774
Tomáš Kukučka Avatar asked Jul 19 '26 11:07

Tomáš Kukučka


1 Answers

With IE, it's always something extra you should do. Try this "special" trick:

IJavaScriptExecutor js = driver as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].click();", find)
like image 147
alecxe Avatar answered Jul 22 '26 01:07

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!