How can I set selenium chrome driver typing speed? - java

I have a ui test that uses selenium chrome driver. I want to set the form filling speed to be slower. I have googled but couldn't see how.
Does someone know how to do this?

In Selenium 1 you can use setSpeed method, in Selenium 2 (aka WebDriver) is, unfortunately, no option like this, at best you can use Implicit waits. However is not really recommended to slow down the Selenium for all tests, you should add waits only for tests which really need to wait for some action to complete.

Related

Selenium WebDriver methods vs. JavaScript executor

I'm developing an application for automation of an upload process on a website. Right now it is working with Gecko Driver on Firefox but I want to change to HtmlUnitDriver. For this application I just started using Selenium. At the begin I just used methods on WebElements (e.g. click() ...). Then there was a difficult part where it doesn't worked out. After that I found the JavascpriptExecutor class. This class was the solution of my Problem. Now I am thinking about totally change from WebDriver Methods to JavaScriptExecutor. I think it will be faster and less error-prone. Am I right? Are there any disadvantages for me to change to JavascriptExecutor?
Thanks in advance.
For QA testing generally one should not use JavascriptExecutor.
Read more about Why using JavascriptExecutor in WebDriver can be dangerous.
But for getting stuff done and fast It is great!
Read more about What are the advantages of using a JavaScript executor in Selenium.
Hope this helps you!

Java Selenium Chromedriver webdriver as fast as possible

I am connecting a standalone program to a website, and I have to read some pages of the website. For first, I used Jsoup, but with this I discovered that some informations that I need are loaded after page load, so I searched for webdrivers. (I am not looking for images or something big, my content are all textual)
Now, i found the ChromeDriver, but it is too slow for my case because it has a lot of options and features.
In my case I need just a step more than the Jsoup possibilities.
It is possible to disable the best part of ChromeDriver options and features to reach this goal?
For example, i saw plugin disabling, but is one by one and is not for every chrome browser on every pc. I didn't found an option like "plugin.disable-all".
Furthermore,in this way I cannot open more than a few instance of chromedriver. In this moment, every instance of the chromedriver is opening a Google Chrome Helper that uses 100Mb of ram.
Hope all is clear
HtmlUnit might be enough for your needs. It does support some Javascript.
It can be used with Webdriver. But might as well be enough on its own
To make your webdriver run faster (but not that much faster), you can run the driver in Headless mode. See these articles for a tutorial on how to go into Headless mode for Chrome.
Before starting the driver, add the --headless argument to ChromeOptions.
Headless mode can speed up your automation by not rendering the browser window, but keep in mind that doing a straight HTTP GET with JSoup would always be faster.
My advice would be to reverse engineer the page a bit more, and see if you can figure out how to query directly whatever the (presumably AJAX) calls are putting on the page. If you can treat those specific requests as an API and only query for exactly what you want, you will be able to get results faster than with browser automation through Selenium.

Error: When i minimize Internet Explorer which is running the automated WebDriver Code

I have written the Selenium webdriver java code to automate the test and its working fine. But I have lot of data input to test my web and it takes time. So when i minimize the IE to do some other task while it is running the automation, it is throwing error:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed
Selenium WebDriver is trying to simulate "real" users interaction with the webpage. If a person can't click on a button not currently displayed, neither can Selenium.
ElementNotVisibleException occurs when the element you want to interact with is not displayed. When you minimize the browser some of the elements are no longer visible, even though they where in maximized window.
You can add scroll using moveToElement() from Actions class every time you want to perform any action (I don't recommend it, you increase significantly the chance for errors), or find another hardware solution, like plugging in another screen, run the test on another computer etc.
According to my experience, the Internet Explorer WebDriver is very oversensitive when it comes to disturbances from a real user while running test cases. It's better to not touch anything at all. ;-)
Try Chrome! This is much more robust and also faster.
Selenium script runs as a simulator. You cannot do another work when script is running. Chrome is fast but while running script in chrome you can not do other task like any other browser. If you minimize window, you will get exception "ElementNotVisible".

Is there a easiest way to migrate Selenium 1.0 code to WebDriver?

I am having old test automation framework developed using Selenium 1.0 and now wants to migrate my code to WebDriver.
Is there any easiest method to do this migration?
I have overridden most of the methods such as type, click, getText, getSelectedLabel, assert etc etc. I see the only method is to re-write all methods again from scratch, I have already started this process but If I continue with the same method It will take many days for me.
Please suggest if anyone has any better approach.
Thanks in advance.
They are completely different technologies. There is no way to migrate them over to selenium 2 per se.
Luckily, the recent Selenium releases have implemented what's called "WebDriver Backed Selenium" so technically if you are using those tests, it's implicitly running them "as" WebDriver tests.
Other than that, no, there is no easy way.
I had the same issue - we are migrating our entire regression suite over to S2 now :)
In the Webdriver documentation, they explain a method to start migrating from Selenium RC to Selenium WebDriver.
Basically, is creating the selenium object like this:
WebDriver driver = new FirefoxDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, "http://www.yoursite.com");
the main problem with this migration (instead of changing the whole code) is the wait for page to load. As they say, the command WaitForPageToLoad returns too soon. The getEval is another command that you have to change.
I think that the best approach is to make functions with the main commands that differs from Selenium RC to Selenium WebDriver, and, once everything is "working" keep modifying your code until no Selenium RC is present. This is how we did the migration, and we had lots of lines of code.
This is the link, where they explain how to start:
http://www.seleniumhq.org/docs/appendix_migrating_from_rc_to_webdriver.jsp#migrating-to-webdriver-reference

Selenium, click on element, hangs

This is about selenium webdriver in java. If clicking on an element, usually it goes fast but sometimes when server is busy it will say Connecting... at the top of the browser and hang. Usually to deal with waits, the code is: driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
but in this case when the server hangs on a click(), this doesn't throw an exception after the time limit, since the webdriver does not start counting until the click finishes connecting to the next url. Did anyone deal with this before, and how?
Is there a way to time completion of click() and submit()?
Yes, this is a known problem and as of Selenium 2.21.0, there is a way to go around.
The problem is that implicit wait is designed to wait for unloaded elements when you search for some, but the click() method just waits until the browser states that the page is fully loaded.
Try driver.manage().timeouts().pageLoadTimeout() which is a new method in 2.21.0 and should deal exactly with this.
The Selenium documentation states that Click() blocks. If for any reason, Selenium believes the page isn't completely loaded, then your Click will hang your test.
I've found that the easiest work-around is to completely skip the click event and use:
element.SendKeys(Keys.Enter);
instead. You get a two for one special - it doesn't block AND you're testing accessibility since many impaired users only use the keyboard to navigate anyway.
When selenium hangs update your firefox version to be as updated as selenium

Categories

Resources