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?
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.
Selenium RC comprises of two parts: Client libraries for the preferred computer language. A server that launches and kills browsers automatically.
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? 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.
I was able to get this working with the Java client in Selenium RC by calling
and then
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With