How can we override the click event of Webdriver at Abstract level.

瀏覽次數:746 次
跳到第一則未讀訊息

Prashant Kajale

未讀,
2015年3月27日 凌晨2:01:212015/3/27
收件者:seleniu...@googlegroups.com
Hi,

While running test from my frame work against Chrome, most of the testcases fails with exception :-Element is not clickable at point (326, 792.5).

We have a work around for this using javascript.

But there are hundreds of click commands used in framework where causes issue while running against chrome browser.
So how can we override the click command of webdriver at one place with the available workaround and not at each place where this command is called.


Thanks,
Prashant.

Krishnan Mahadevan

未讀,
2015年3月27日 晚上11:01:102015/3/27
收件者:seleniu...@googlegroups.com
Prashant,

There is no straight forward way of doing this [ in any ways you would be required to sweep through your code and make changes in a lot of places ].

So what I would suggest is that you please consider creating a utility class [ Lets call it WebDriverUIActionsHelper] and define a click method in it, which takes in a WebElement as an argument and internally attempts to first invoke the WebElement.click() and if that doesn’t work, then resort to your JavaScript work-around.

That way, you still have abstracted out all the actual WebElement.click() calls and you don’t have to apply the workaround in each and every place.

Would that work for you ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/53367d39-ada6-4874-be89-4122536f309a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Neha Verma

未讀,
2015年3月30日 下午2:37:512015/3/30
收件者:seleniu...@googlegroups.com
This Issue Max no of time occurs into Chrome,Can be do such way to prevent this using JS executor,and click on WebElement. :
Capabilities cp = ((RemoteWebDriver) driver).getCapabilities();
                if (cp.getBrowserName().equals("chrome")) {
                    try {
                        ((JavascriptExecutor) driver).executeScript(
                                "arguments[0].scrollIntoView(true);", webElement);
                    } catch (Exception e) {

                    }
                }

                webElement.click();

Mukesh otwani

未讀,
2015年3月31日 中午12:43:232015/3/31
收件者:seleniu...@googlegroups.com
Hey Neha,

thanks for a nice code. It worked for me. Cheers 
回覆所有人
回覆作者
轉寄
0 則新訊息