Java -jar c: selenium selenium-server-standalone-3.0.1 -role node. 12 requests waiting for a slot to be free. The Hub has received requests with no slots available. It placed them on a queue.
- Waiting For A Slot To Be Free Selenium Ide
- Waiting For A Slot To Be Free Selenium Webdriver
- Requests Waiting For A Slot To Be Free Selenium Grid
- Waiting For A Slot To Be Free Selenium Sulfide
“Don't wait. The time will never be just right.” Napoleon Hill
Selenium Element not found
Waiting For A Slot To Be Free Selenium Ide
Are you testing a web application using Selenium and keep getting an [error] Element .. not found error message? One way to work around this and similar issues is to use a waitFor command.
Why the Pause command stinks
You may be thinking, “Wouldn't it just be easier to use pause commands throughout my script?” In rare instances, a pause command may be the way to go, but in most instances it's a very poor choice.
When using a pause command in your test, you have to try and make the test wait just a little bit longer than what you believe the longest anticipated response time will be.
The problem with this, of course, is that the response time could be considerably longer than anticipated – which means you end up bumping up your wait to be even longer than the longest expected delay.
Those long pause times will slow your test run time considerably, which is not cool. The solution is to use a method that's flexible enough to synchronize with longer and shorter delays.
WaitFor
WaitFor commands are not hard waits; meaning that they will, by default, wait up to 30 seconds to find an element, but if they find an element before 30 seconds, they continue without waiting the remainder of the time. (If you're familiar with HP's Quick Test Professional, it's similar to an objects exist method or WinRunner's generic obj_wait_info statements.)
Why use Synchronization Points?
In test automation, this concept is often referred to as synchronization. Adding synchronization points in your script facilitates your test when you need to wait for a response from an application. This is important — because when testing a web application, server response times can vary for any number of reasons.
To help make your scripts more reliable, you should get into the habit of using synchronization points like one of the many waitFor commands available in Selenium.
For this sample test application I use AJAX to populate it. More often than not, an Element not found error occurs when running a test against this application. This is due to issues with the element not being loaded into the DOM because it's in the process of being rendered in your browser. One way to work around this issue is to use a waitFor command.
Let's check out a WaitFor quick example:
Selenium has a bunch of waitFor commands. In this example we'll use the waitForElement, but you can use whichever command works best for your situation. To make this quick I'll use the Firefox Selenium IDE, but you'd use the same waitFor methods if you were coding using the Selenium APIs.
Selenium IDE
- For the Base URL, navigate to:
- From the HPSupport.html page, enter the following values:
- Is this supported = DELPHI_ADDIN
- Right click on the first row, first cell, Delphi Controls CLX and select Show All Available Commands>asserText css=td Delphi Controls CLX.
- Stop recording. Your IDE Table results should look like this:
- You should see the error [error] Element css=td not found. (If you don't see this error, it's ok-you'll still want to add a waitFor, however. It's a good practice since response time will vary for each test run.)
Waiting For A Slot To Be Free Selenium Webdriver
Requests Waiting For A Slot To Be Free Selenium Grid
Add a waitForElementPresent command
Now, let's add a waitForElementPresent command and rerun our test.
- Right click on the assertText command and select “Insert New Command” from the menu.
- Command = waitForElementPresent
- Click on the Find button, this should highlight the first cell in the first row.
- Rerun the test by clicking on”Play current test case” –the run should pass and your log should be error free!
It's Elementary
That's the basics on how to use the waitFor commands in Selenium. Stay tuned for more Selenium 101 posts in the coming year.
To get started using Selenium WebDriver in Java or .Net check out my other post:
- Selenium 2.0 WebDriver – How to Get Started with Eclipse, Java & IE
- Selenium 2.0 WebDriver with Visual Studio, C#, & IE – Getting Started
Waiting For A Slot To Be Free Selenium Sulfide
hangs when I create a node on one machine which specifies a hub on a
different machine. After I run the command to start the node, I check
the grid/console webpage of my hub and it displays that it is
listening to my node momentarily. Upon refresh, it says (cannot rbe
reached at the moment). Creating a node on the same machine as the hub
works fine. I run the test case anyways (the hub is not listening to
nodes that are on the same machine) and here is the output. I tried
variations of nodes and hubs using standalone 2.2.0 and 2.1.0, and it
all seems to be the same problem. It seems to have know about the node
somehow because, if I run the node, it will hang, and eventually in
the hub's URL/grid/console webpage it say that the node cannot be
reached. However, if I kill the node, and rerun the same command
(using the same port I previously tried using with the node), in the
hub's terminal, it prints a warning saying:
WARNING: Proxy 'URL :htttp://192.168.10.1:7773/wd/hub time out :
300000' was previously registered. Cleaning up any stale test
sessions.
Thanks for the help in advanced!
-Daniel
On Jul 27, 11:30 pm, Krishnan Mahadevan
<krishnan.mahadevan1...@gmail.com> wrote:> garcia.pared...@gmail.com> wrote:
> Javier, if the node is not available, I have seen the Grid throw back an
> error saying capability not present. I havent seen it wait.
>
> If the capability matching is indeed the problem, then you have a couple of
> options.
>
> 1. Spawn the webdriver node that is hooked to the hub with a nodeConfig file
> (u have to use the -nodeConfig parameter) and define capabilities such that
> the grid can redirect the request to the node.
> 2. Revisit your code, get away from using DesiredCapabilities c =
> DesiredCapabilities.internetExplorer() and instead use the following
>
> DesiredCapabilities c = new DesiredCapabilities();
> c.setBrowserName(DesiredCapabilites.internetExplore().getBrowserName());
>
> and then retry. Hope that helps.
>
> Thanks & Regards
> Krishnan Mahadevan
>
> 'All the desirable things in life are either illegal, expensive, fattening
> or in love with someone else!'
>
> On Wed, Jul 27, 2011 at 11:47 AM, Javier Garcia Paredero <
>
>
>
>
>
>
>
> > Yes. Actually if i open in the browserhttp://localhost:4444/grid/consoleIcan see the following
>> > - {platform=WINDOWS, ensureCleanSession=true, browserName=internet
> > 1 requests waiting for a slot to be free.
>
> > explorer, version=9}> >> On Tue, Jul 26, 2011 at 8:34 AM, Javier Garcia <garcia.pared...@gmail.com
>
> > Looks like it cannot find the node
>
> > 2011/7/26 Eric Bass <3m8...@gmail.com>
>
> >> are you running the code below on the same machine that the hub is on? if
> >> not you should replace localhost with either the hostname or the IP address
> >> of the hub server.
>
> >> > wrote:> >>> hubhttp://10.128.24.28:4444/grid/register-port 5556 -browser
>
> >>> Hi
>
> >>> I am trying to test using Grid2. I have an ie9 browser in a Windows7
> >>> VM
>
> >>> First i start the hub
> >>> java -jar selenium-server-standalone-2.2.0 -role hub
>
> >>> In the remote host i register the node
> >>> java -jar selenium-server-standalone-2.2.0.jar -role webdriver -