Selenium IDE #6

Closed
obromios opened this Issue Mar 23, 2013 · 8 comments

Comments

Projects
None yet
2 participants

This is a great site thank you.

Here is a problem I posted on Stackoverflow and no one answered within 7 days, so maybe it is a real issue.

When I run my selenium test without the turbolinks gem installed in my Ruby on Rails app, the tests pass. When I include turbolinks, the tests fail. For example if the test starts off

Open /
clickAndWait link=Sign in
type id=session_email any@example.com

Then I will get an error

"[error]Element id=session_email not found.

When I look at the page source, the session_email id is still there with turbolinks installed. I found this page, http://www.digitalkingdom.org/rlp/tiki-index.php?page=Selenium+And+Javascript, which seems to indicate there could be a problem with detecting the page has fully loaded.

Is there away to fix this without changing hundreds of lines in my test suites? If not, is there a reliable selenium method that can test that a turbolinked page has fully loaded?

Chris

Owner

reed commented Mar 24, 2013

Hey,

It seems like this (dealing with ajax) is a common issue for automated javascript testing frameworks. I'm not all that familiar with selenium, so you might want to take my advice with a grain of salt.

Is there a way to fix this without changing hundreds of lines in my test suites?

It might be possible for you to extend Selenium with your own custom code, but even then, you'd probably still have to change the syntax of your tests in some way.

If not, is there a reliable selenium method that can test that a turbolinked page has fully loaded?

Again, you might be able to write your own, but as far as native functions go, I'd think your best bet would be to use the waitForElement function. So your example would look something like this:

Open /
click link=Sign in
waitForElement id=session_email
type id=session_email any@example.com

Would that work?

I will get in contact with the Selenium project and see if there is any interest in extending the code.

I will try the waitForElement and let you know the result.

Chris

Hi

I tried the waitForElement but it is not valid Selenese. However, it led me to the waitForElementPresent command, which is valid and appear to do the same thing. In one of my test suites, I added this command after every clickAndWait (as indicated in the previous comment) and it worked in every case, apart from one place. This was the only place I have javascript, and it was a standard confirm after delete command. So the code looked like:

clickAndWait link=Delete
waitForElementPresent Are you Sure?
assertConfirmation   Are you Sure?

and the waitForElementPresent could not find the "Are you Sure".

I deleted the waitForElementPresent line just at this place in the test i.e it the code went back to

clickAndWait link=Delete
assertConfirmation   Are you Sure?

and the test passed. However, I am not sure if this is reliable, or whether waitForElementPresent is not neeed with the Javascript confirmation?

Overall it looks like this is on the right track, although the Selenium IDE loses much of its spontanaity as it is no longer possible to make and edit a test suite by recording mouse clicks when running turbolinks. I will take this up with the Selenium project.

Chris

Owner

reed commented Mar 26, 2013

In my suggestion, I changed the clickAndWait command to just click because the waiting will be done on the next line. I don't know if that helps or changes anything, but it seems more logical to me.

I would think that the waitForElementPresent Are you Sure? command wouldn't work because the text isn't an element. Isn't there a waitForTextPresent command that would be better?

You are correct, there is a waitForTextPresent command. However, this did not help. When I put it in, the test stalled at that point, and if I looked at the browser I could not see the delete confirmation message. Somehow the waitForTextPresent seems to be stopping or delaying the display of the confirmation. If I take out the waitForTextPresent it works fine. I wonder given it is a javascript message, whether the clickAndWait is sufficient?

You are correct about click being sufficient when followed by the waitForElementPresent.

I have posted a new topic concerning Turbolinks on the Selenium User group but have yet to have a response.

Owner

reed commented Mar 27, 2013

Yeah, you're right, waitForTextPresent wouldn't work. If you take a look at the documentation here, I think you'll see that how you're doing it is sufficient.

I would think that how you have your tests now is how you should keep them. You wouldn't want them to be tailored for Turbolinks. You'd want them to pass regardless of whether Turbolinks is enabled.

OK, then I understand an approach to make the Selenium IDE work under turbolinks. The only problem is that by the time I change all my tests, I will be so familiar with the Selenium language, then I may as well just work with Selenium language directly rather than work with IDE replay facility. But I guess we all have to grow up sometime.

Thank you for your help. I will post a summary, pointing to this issue report, on my Stack Overflow Turbolinks/Selenium question. If the Selenium project comes up with any information on this I will let you know.

Owner

reed commented Mar 27, 2013

You're welcome. I'm glad I could help you.

reed closed this Mar 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment