Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium RC and input control events

Tags:

We have web UI project in MVC and for automated testing, we are using Selenium, it's a brilliant tool. But I am facing some problem in raising events with Selenium.

Scenario: I have a textbox which expects +ve value and bubbles up an error (javascript) when entered any -ve value and we hit tab from that textbox or clicked outside anywhere on the page.

It works fine with normal user interaction with the website but when using selenium I am not able to achieve this behavior. I am putting some text with Selenium.Type('elementId',-ve value) the event doesn't get fired and the error doesn't bubble up.

I tried using FireEvent("textboxId","blur") but its not working. The only workaround is Focus on the textbox, add some value, use FireEvent("textbox","blur") and then Focus on some other textbox.

Has anyone got any idea to resolve this?

like image 645
Miral Avatar asked Oct 01 '09 09:10

Miral


People also ask

What is difference between Selenium RC and WebDriver?

Selenium WebDriver is purely object oriented API, whereas Selenium RC is less object oriented API. WebDriver is entirely based on object oriented programming languages like Java, C#, etc.

What are the two components of Selenium RC?

Selenium RC comprises of two parts: Client libraries for the preferred computer language. A server that launches and kills browsers automatically.

How does Selenium RC work?

Selenium Server communicates with the running test client and drives the browser after receiving instruction by RC Server. The browser receives the instructions from Selenium Core and relays its response to the Selenium RC Server. Using the response received by the RC Server, the test results are displayed to the user.

What is Selenium RC commonly known as?

What is Selenium RC? Selenium Remote Control (RC) was the main Selenium project that sustained for a long time before Selenium WebDriver(Selenium 2.0) came into existence. Now Selenium RC is hardly in use, as WebDriver offers more powerful features, however users can still continue to develop scripts using RC.


1 Answers

I was able to get this working with the Java client in Selenium RC by calling

  • type("id=textboxid", "newValue");

and then

  • fireEvent("id=textboxid", "blur");

Did you get any indication as to whether the "blur" event was being fired at all? I wonder if maybe the locator wasn't quite working right to fire the event.

Whatever little tricks you need to pull to get it working, to avoid doing this for every field, you should either wrap your 2-3 calls in a function if using an RC client, or register some user extensions to do it in one step if you're using the Selenium IDE.

like image 153
Chris Jaynes Avatar answered Nov 15 '22 06:11

Chris Jaynes