Why are Selenium IDE playback controls inactive? (How can I run recorded tests?) - testing

I started learning how to use Selenium today. I have never used it before. I downloaded the Selenium IDE (1.0.10) plugin for FireFox (3.5.16). The way it's behaving is not matching up to the docs.
When I click the record button and perform actions in my browser, nothing happens in the IDE (nothing is recorded). (Actually, initially it did record, but now it doesn't) I tried restarting FireFox and that had no effect.
Also, the main controls are now inactive. I've included a screen shot to show what I mean by that. The controls remain inactive even it I click or double click on the name of a test case in the panel on the left.
And one final question -- it appears that a Selenium test case mentions Chrome in its default configuration even though the docs say you can only record tests using FireFox. Should I do anything about that?
If anyone can shed light on any of the above mysteries I would appreciate it. Thanks!
UPDATE
I restarted FireFox again and now it's recording actions, but the controls are still greyed-out as in the screenshot, so I can't play back the test.

The issue is that you are not in the HTML runner mode. The IDE has no concept of ruby or python or c# or Java. That is up to plugins which just essentially do a find an replace.
*chrome means Firefox Chrome. Something that has been around for a lot longer than Google Chrome the browser. It means use the browser chrome which removes a couple sandboxing issues.
If you want to play back the tests you can't go out of the table mode otherwise the IDE won't understand what to do. The code in the screenshot should be stored in a .rb file and that should be executed.

Let me try to unravel mysteries -
As soon as you launch the IDE it would be in recording mode. Do you see last Red button which is enabled.
IDE Tests can be executed only when in the selenese/html format (aka table format). I guess you have changed the format to ruby (I guess so), from Option > Format.
To be able to execute tests change it back to html from option > Format > HTML
Take my words, IDE is only and only for firefox

Related

Cannot access Selenium IDE commands on right-click

I'm using Selenium IDE 2.9.1 to automate my regression test cases.
Normally when running Selenium IDE in Firefox, if you right-click on a browser element - whether it's text, a button, a field, etc. - a list of potential commands comes up. This had been the case for me as of last week.
This morning, however, I'm finding that right-clicking in the browser does not show the commands anymore. This is making writing my test scripts a lot slower.
Can anyone tell me why this might be happening, and/or how to fix it?
A similar question was asked (Can't see Selenium IDE commands on mouse click), but it was never answered. So I'm asking here.
I had a similar problem - no "Show all available commands" when right clicked on object. A downgrade to firefox to 50.1.0 helped.

Move target out of bounds exception

I am writing tests for a web application and all went well until I had to choose an option from a menu and that option displays a drop down list when hovered or clicked. When I click an option from the drop down list, I get the following error:
MoveTargetOutOfBoundsException: Element cannot be scrolled into view
Does anyone know what this error is about and what I should look for in my code?
Selenium version 2.25.0, java version 1.6.0_31
I've been checking some selenium and google groups regarding this issue in older versions https://groups.google.com/forum/?fromgroups=#!topic/selenium-users/EuZ7a6_lB9Q
http://code.google.com/p/selenium/issues/detail?id=3075
http://code.google.com/p/selenium/issues/detail?id=4102
a more recent discussion
Is it a known issue for Selenium 2.25.0 or is there a way to fix it? I recently upgraded to Firefox 15.0 :|
Note: I found a temporary solution until someone magically fixes this...since I can't find where the problem is...
I run the code before that point where it crashes, I put it to sleep for 10 seconds, I manually click the menu and the option from the drop down list, the window I want is displayed and the code continues with actions from that point. It works for now...I hope this will be fixed since I can't believe that I can run a script in Selenium IDE but I can't run my java code in WebDriver ...this is crazy :|
I guess you are trying to click an element from a dropdown.
You should keep in mind, that Selenium helps you replicate exact human behavior. So if the code fails because the element is not visible, it is probably because the element is not visible.
To make it work, you might want to put a click command on the menu before the failing bit of code.
(to replicate the sleep 10 seconds manually click the menu button method you are using)
Once again, if you can show us your code and also the HTML snippet of the Menu section, we can provide an exact solution.
Maybe you're opening new popup window while opening select box.
This may help you:
WebDriver.FindElement(By.Id("someInputBox")).SendKeys("hello");
(IJavaScriptExecutor)WebDriver).ExecuteScript("document.getElementById('windowOpener_Button').click();");
WebDriver.SwitchTo().Window("newDisplayedWindowPopupName"); // continue to test

Selenium clicks on a wrong link (or does not click on a link at all) on certain machines

I am using Selenium WebDriver 2.5.0 (tried 2.13.0, it did not help).
I am trying to click on a link like this:
driver.FindElement(By.PartialLinkText("Customer - Creation").Click();
Before it worked, but I have tried to run the scripts after 3 weeks and
I observe 3 different behaviors on 3 machines:
Machine A: There is no click on the link at all, also there is no error.
Machine B: It clicks a different link! Sometimes one above, sometimes one below.
Machine C (Virtual): It works.
I have not fully tested this (spent half a day today), but did anyone stumble upon such a behaviour?
I have restarted my PC, re-added the Selenium libraries.
"SendKeys(Enter)" helps, but this issue happened not only to links, but to at least radio boxes as well, where "SendKeys(Enter)" does not work.
Please share your thoughts.
Update: Browsers are the same on at least 2 machines, Internet Explorer 8.0
Answered by nebehr.g...#gmail.com at Selenium Issues:
This issue keeps popping up from time to time and is usually returned with request for clarifications. The bottom line is, InternetExplorerDriver calculates coordinates of some objects incorrectly and clicks in the wrong place. One reason for this is zoom value other than 100%; however it is reproducible for some controls for 100% zoom as well.
I suppose it would be helpful if you could create a sample page to demonstrate this issue. In the meantime why don't you use Javascript click() method for offending controls?
http://code.google.com/p/selenium/issues/detail?id=3052
One other thing to check for is the screen resolution (not the desktop resolution but the system level size of text and icons). I have two laptops in my office that are you used for testing, one running Windows 7 and the other running Windows 10. On both, the screen resolution was greater than 100% and Selenium was having problems moving the mouse to the correct location for mouse events like click and hover. As soon as the screen resolution was set to 100%, all mouse actions worked correctly.
Windows 7: http://windows.microsoft.com/en-us/windows7/make-the-text-on-your-screen-larger-or-smaller?v=t
Windows 10: https://superuser.com/questions/951199/windows-10-system-font-size-change
There is a lot of useful info in Andrey's answer and in the Selenium issue he mentions at https://code.google.com/p/selenium/issues/detail?id=3052. Just to tie all those pieces of info together and offer a successful workaround...
I too am experiencing the issue of clicks occurring at the wrong screen coordinates -- four years after the OP first mentioned it! As others have said:
The issue is related to InternetExplorerDriver. I have the problem
when testing IE 9, but not Chrome, Firefox or even IE 8.
As mentioned in the Selenium issue, the website I'm testing uses frames.
I tried several workarounds suggested in this post and elsewhere. All of the following did NOT help:
Updating to the latest InternetExplorerDriver (version 2.47.0)
Maximizing the browser window.
Setting browser zoom to 100%.
Using an action chain, with or without move_by_offset, instead of WebDriver's click() method.
As suggested by Andrey, what DID help is using JavaScript instead of WebDriver's click() method. Here's a line of Python code that does the trick:
driver.execute_script("jQuery('{}').click();".format(css_selector))
This assumes that "driver" is an instance of Selenium WebDriver, and "css_selector" is a string identifying the element you want to click, and that jQuery is loaded.
Sounds like the element isn't present in the page's HTML, but is instead added dynamically once the page is loaded. What happens depends on how fast the machine is and how unique the text is. I'll bet that if you added a long sleep (e.g., a minute) you'd get the same result on all 3 machines. If so, that indicates the single most classic Selenium testing problem - trying to act on pages that aren't complete. You need to find an element to wait on that will guarantee the presence of the link you'd like to click on.
I just had the same issue in FireFox. The zoom was at 100% and the selection was by xpath an certainly correct. Turned out the problem disappeared when I maximized the browerwindow!
code :(python api)
self.driver.maximize_window()

Some mouse clicks don't register in Selenium

I've got a rather Javascript-heavy page with lots of contents generated via AJAX or other scripts. On some of these elements Selenium can record mouse clicks, while on others it ignores them. I haven't found any correlation. Perhaps there are some known common scenarios where Selenium cannot intercept mouse clicks?
Unfortunately not all clicks in Selenium are equal. Some are mouseDown and MouseUp or a variation on that. I would play around with that to get your app working.
Unfortunately Selenium IDE has been misrepresented. It is a Record/Tweak/Playback tool not a record/playback tool.
There's no list of actions that are unreliable. In my experience there's no pattern to which elements work, but it's consistent throughout executions of the test. In case you were thinking about it, playing around with locators or UI-Elements is very unlikely to improve your results.
I recently had a situation with a number of dropdown menus, all implemented in the same way, on multiple different pages. On certain pages, dropdown #2 and #3 wouldn't work, yet on other pages they would work, but dropdowns #1 and #2 wouldn't.
As has already been pointed out, the best thing to do is stop thinking about Selenium IDE as a record-playback tool.
On a sidenote, you may be asking this question for a similar reason I was, which was wanting to use Selenium IDE as a frontend for teammates without Selenium programming experience to create tests with, then one thing I did find helpful was extending the Selenium IDE by adding a Command Builder, which allows you to control what appears in the right-click menu when using the IDE.
This means you can press record, go about recording your test as normal while keeping an eye on what has been recorded. Once you see Selenium IDE has failed to record an action, you can just right-click the element and the action you wanted to record will be easily available.
Not a solution to your original question, but it's helped me out. It's very simple to write an extension to the right-click menu, there's some really good examples on this Selenium website.
I'm a 100% selenium noob, but I had the same problem and solved it through the following workaround:
Right-click the to-be-clicked item
Choose a random command that has the entire locator text, e.g. assertText //div[2]/div[5]/table/tbody/tr[1]/td[1]/div IR or something. Look inside "Show all available commands" too.
In the Selenium IDE, change the command to "click" and remove the 2nd argument (the Value field; if any)
Hacky, and should be easily improved with a custom command in the right-click menu, but for now this works fine for me.
Did you try clickAt with location (0,0)? It sometimes helps
If you have assigned an ID to the element you want to click I would suggest you try a simple script, you can perform this through the IDE:
runScriptAndWait
jQuery("#yourButton").trigger('click');
I have used this in the past and it works just fine.

Automation of DOH Robot tests interrumped by Pop-up message

In order to automate DOH tests during our build process, I use Selenium RC to launch different browsers (IE and Firefox) on a server placed on a different domain than the build machine. Each browser is directed to our runTests.html in order to start DOH.
Sometimes, when a test that uses doh.robot starts, the following message is shown:
"DOH has detected that the current web page is attempting to access DOH, but belongs to a different domain than the one you agreed to let DOH automate. If you did not intend to start a new DOH test by visiting this Web page, press Cancel now and leave the Web page"
but since these tests are unattended it just sits there waiting for someone to click OK, and Selenium times out (in IE 8 it seems like the pop-up disappears automatically but the robot does nothing afterward).
As I said, it doesn't always happen. After you click OK on the Pop-up, the message will stop showing, and the message can go away for several sessions, but then it will show again in which seems to be an arbitrary way.
Does anyone knows a way to prevent this pop-up from showing?
This is probably not the correct way to do it, but in util/doh/robot/DOHRobot.java, you may be able to modify the code to not check that or always simulate pressing "OK". I haven't tried it myself, but I may also need to do that for some of our automated testing.
When the DOH robot is initialized, it first tries to click in the upper left corner of the page you are trying to test. If you obscure this div (you can see it with firebug), then the message will pop up. I think the problem is that your page isn't always loading up quick enough.
It is somewhat of a challenge to fix this. I haven't used DOH in awhile, but I don't think there is any way you can use a setTimeout to fix this. (You can try using setTimeout on the doh.run command, but it might be the case that the DOH robot clicks that div before parsing any doh commands.)
Another thing you might be able to do is add a sort of "wait" command to Selenium, or whatever shell command you are using to fire up the system.