Automation of DOH Robot tests interrumped by Pop-up message - dojo

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.

Related

Can Selenium handle Browser Notifications in the OS?

In the screenshot below, I make a VoIP call from an incognito window to an account logged in in a normal Chrome window that is minimised. Therefore I receive the Chrome notification in the bottom right corner.
I am tasked with creating a front-end test to validate the text in the notification window, that would work for Windows, Linux, and MacOS situations.
Now this may or may not be a silly question, but is there a way that selenium can handle tasks related with this notification, for example validating the text that appears in it? I can't find anything online and I understand it is not a DOM element, so I wonder if it is even possible. Could someone provide a basic start point for finding this non DOM notification element if it is possible / how to go about testing it in the front end if selenium is not the answer? TIA.
Notification example

Selenium element.click() does not work

Hello: I am using Selenium/Java to grab a PDF from a website. The website does not generate them in advance, but only after I clink on a link. When I do, the web server goes away for a few minutes, and then comes back with the content.
I'm using Firefox, and its built-in PDF viewer. When I click on the download link from the main browser window, it opens another window to receive the PDF content. In a few minutes the child window is filled with the PDF content, and all I need to do is click a download button on the Firefox toolbar, and then press a Save button on the confimration dialog. I have done both of these things, successfully, sometimes.
My problem, sometimes occurs when I execute the code to click on the child window's download button...
WebElement element = driver.findElement(By.id("download"));
element.click();
Sometimes, it just doesn't work. The statement:
driver.findElement(By.id("download"))
...never throws an exception, so it appears to always be successful. Yet, the subsequent element.click() will often not produce the expected results.
I've thrown about 100 darts at this problem, but I can't seem to find one that produces consistent results. I've tried introducing delays, calling findElement several times, trying to use the driver on the child window in ways to confirm its connection to that window (all with positive return values), but nothing seems to help make element.click() on the darn download link successfull.
I have found Selenium to be a rock-solid solution, especially when working through the primary window...it never misses a beat, and I'm really quite impressed about that behavior. This is my first Selenium project, and I hoping someone that has used it a bit more, might have a suggestion for this particular problem.
It's hard to answer this question without additional information about how the child window is populated. If the child window is using javascript to add the button to the page and define its behavior (which is likely), then the element could be actually present on the page when you look for it (i.e. no error will be thrown), but it might not be active yet or prepared to be clicked.
It might be a good idea to look at the element definition in the source for the child page to get a better idea of how the button is coded. If you have access to the web developers who designed/implemented the button even better. If you can wait to perform the click action until the button is in the desired state, this should solve the problem.
Additionally if the page is coded using a dynamic framework like Angular, you might be better off using Protractor for testing, which is based off of Selenium, but which is aware of updates in the view as they are occurring.

Element link not found in Selenium

I am executing a simple recorded script in Selenium , in which i just search a page in Google and then click it , but when Run that recorded script it is giving me the "Error [error] Element link not found".
And following is the Script which i am running,any help would be very useful.
New Test
New Test
open
/
type
q
Bill Gates
click
link=Bill Gates: Chairman
click
link=Bill Gates: Chairman
I got the same error message while going through the tutorials online. I found out that the scripts were running too fast for FF to load the links. If you slow down the playback by moving the green button on the Fast-Slow bar to somewhere in the middle the scripts run without any errors.
I guess I know the answer. It might be bcz of any javascript error(you can see that on the status bar at the
Right corner(IE)) or that link element might not be placed correctly in the box(box model).
Here you can use
Selenium.focus("link=text")
:selenium.keyPressNative("10") . It presses the enter key.but while selenium is executing this statement
Do not change the focus from your AUT (don't touch the mouse).
In IDE ,just paste the above statement on click().
Well, I don't think you have to slow the speed down. You know the problem is caused by clicking on the link before it is available, so you could add an extra command waitForVisible (e.g. link=Bill Gates: Chairman) before the clickAndWait command.
Im assuming you are using Google instant as there is no "click search button" command, the link is probably not preset because selenium is not waiting for Google instant to respond or the javascript to render the link. If you manually add in a click command to search it should solve it.
My solution is almost the same as Cuongs. Though I change the speed by using a command and change it back afterwards.
Before you click the link, you can set the speed to slow:
Command: setSpeed
Target: 3000
You can change the speed afterwards again to ~1000
I also had same problem. I did two things which fixed the problem. I changed the speed in Selenium IDE from fast to slow (located at top left of IDE), and I minimized the IDE after hitting play button. I guess for people using only one monitor, minimizing Selenium IDE would help the test find the thing it is looking for; for ppl with two screens, opening Selenium IDE in one screen, and opening browser in another screen would be best.
Info: Installing this plug-in (Selenium IDE: Flow Control) fixed lots of unexpected errors for me while playing with Selenium IDE:-
https://addons.mozilla.org/en-US/firefox/addon/flow-control/?src=dp-dl-othersby

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

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

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.