Selenium hanging and timing out on basic page interactions on OWA. - ruby

I'm using Selenium with a local FireFox browser to access live.com's spam box and read the email. For testing purposes, I've been using "binding.pry" to interact with my script and see where the problems are.
When I try to find the element representing an inbox message:
driver.find_element(:css,"#messageListContentContainer .ia_hc")
I get this error after 60 seconds:
Timeout::Error: execution expired
from /usr/lib/ruby/1.8/timeout.rb:64:in `rbuf_fill'
But, as I'm in Pry, I can quickly repeat the same command. After about 5 or 10 seconds, it finds the element.
Obviously I can get around the problem by putting a before, rescue, retry block around the call, but that means I'll have to wait 70-80 seconds to click a single email. Does anyone have any idea why find_element is taking so long that it times out, or why it doesn't time out the second time? Is it because the live.com (called "Outlook Mail" on the website) has a huge ammount of elements to search through? Is it something with the JavaScript they are using?
I've been able to duplicate this issue with both Firefox and PhantomJS
UPDATE:: I've found this is happening with all of the calls after any page refresh. I can call driver.page_source and I have the same problem. It seems selenium can't interact with the browser for a certain period of time after the page has refreshed. Could it be that selenium is having trouble reading everything off of the web page?

I have seen this happen in my own tests, but on an intermittent basis, and never completely reproducible. What seems to happen is that Selenium WebDriver just becomes blocked and unresponsive.
I know that I have just had to resort to rescuing the error, logging, and retrying in my code. After a few retrys, Selenium WebDriver seems to become responsive again and I'm able to continue on in my tests from there.
I have contacted the maintainer of the Ruby WebDriver gem, and he needs a reproducible test to be able to do some solid debugging. If you are able to provide a reproducible test case, please share it with us so that we can look into this issue. You can use this gist as a starting point to share with the community.

The problem just magically disappeared. It's not happening anymore and I can't duplicate it. Best of luck to the selenium crew finding it, it seems to come and go randomly.

Related

In which circumstances a websocket connection will close or re-open

I use many web applications everyday. I noticed some apps seem better than others at keeping the WebSocket connection active and to give instant feedback. If I am looking at others tabs, some web site will instantly indicate in the tabs' list that I received a new message, while some other will take more time or require me to get back to the window. Some websites are not consistent: sometimes they will give an instant feedback, sometimes I will have to refresh. I noticed often a website won't even be consistent across the multiple tabs I opened of it: Some tabs will notify that I received a new message, some other won't.
I would like to understand the rules that determine in which conditions my WebSocket connection will close or reopen by itself. Seems quite complex, since so many web apps are getting it wrong. Yet, I failed to find those rules.
I made all the searches I could think about. I can't believe that question has not been asked on StackOverflow yet. MDN does not say much, and even the specification have not been helpful. It seems the WebSocket connection will close by itself when I close the tab. It shows the connection will close automatically in some circumstances. Yet, even that behavior seems not to be documented. The specification only says something vague about the status code 1001 and "browser having navigated away from a page", but I've not seen anything about the browser being responsible to call "close" with that value. It makes me think all of this might be browser-defined. Yet I still need to know what to expect among the main browsers.
Any of you can tell me more on the matter?
Thank you

Watir Webdriver Detection

Is there a way to detect whether someone is conducting web testing using watir-webdriver on your site? I have read somewhere that it is fairly easy to detect watir/selenium, but I never managed to get more details about it.
I have tried UserAgent detection, but that's not something very useful as far as it's easy to change it.
Right, I will make my comments into an answer as requested.
I doubt if it's possible. The idea of Selenium is to automate browsers by simulating actions like real users. You can't possibly detect it from server side, unless Selenium fails to simulate (e.g. click really fast, but if the Selenium code is written deliberately to simulate a real user in a slow fashion, then I'd say it will be difficult to detect).
On the other hand, User Agent approach won't work if someone runs it using common browsers with default UA.

Firefox page sometimes loads forever, how to determine cause?

Pages on my website sometimes load indefinitely (shows the circular blue loading animation in the tab, and "Waiting for example.com..." in the status at the bottom) in Firefox. Usually they finish loading very quickly.
Since I can't predict when it will have one of these episodes, and Firefox requires you to refresh the page in order to use the Network tool, how can I determine the cause of this on the rare occasions I see it?
I'm not sure if it is because JavaScript is running or a request for another file hasn't been answered.
This may happen in other browsers, but I generally only use Firefox unless the QA person I work with tells me there is a browser specific issue.
Generally, use the httpfox add-on, Firefox developer tools, and Firebug. Understand your server software and make sure errors are logged. Read the log.
If you can repro the error then you should be able to use a debugger with your server and find the section of code that is processing forever. Maybe there's an infinite loop. Maybe a lock has blocked execution. Maybe a ridiculous query was made to the database.
Otherwise, unless this unpredictable error is causing you to lose money or endanger people, ignore it.

Website running slow in IE with no specific reason why

We have a website that a few people are complaining about it running extremely slow. We're struggling to figure out why and to even recreate it. Most are mentioning that it's running slow in IE.
It's not limited to any specific section of the site, just the whole thing in general.
There's been several developers creating/adjusting the code so it's overly bloated but we can't see any specific reason why this should happen.
Can anyone see why?
We've also run a speed test:
I was running a profiling test with IE on your website and there is a call to:
http://www.playforce.co.uk/-ms-transform.htc
Which is giving error 404 not found and taking 1 second to complete (0.91 sec).
If is found all around your css under this line:
behavior:url(-ms-transform.htc);
Am no expert !! Am welcome to better suggestion and corrections of what i am about to say
You can try using a trial version of Borland Silk meter ..
They tend to measure the speed with which each element loads using various browsers and various geographical locations which are configurable by you.
Also , since only some of the user's are complaining about the speed being an issue you should also check the speed of their internet and their browser version and other addon etc of those users. Because sometimes the problem is not only with the server .
Try the above tool to confirm nothing is wrong in your server and then proceed to checking the client's browser and network.

How to change Opera's proxy settings from Watir-Webdriver?

(This question is loosely related to my previous question)
Hello there.
I have been using Watir-Webdriver with Mozilla FireFox for a week now, and I am quite pleased with it. However, since I am making a test wich tries to connect to some websites multiple times using different proxies, I found that using FireFox was extremely slow. Firefox's starting time is (at least on my computer) about 15 seconds(if you're lucky) so I am looking to find something to speed the thing up. This made me look into other browsers and their start up times. It seems Opera is quite fast. However, since it is 'new' in Selenium Webdriver and thus also in Watir-webdriver there is not much documentation about it.
Enough talking, time for the question:
How can I, using watir-webdriver(or Selenium-webdriver directly), change the proxy that Opera uses for connections?
I'm not quite sure I understand the use case, but as a hack/workaround you can change any Opera setting from OperaWatir by loading opera:config and running JS in it to set preferences. In other words,
browser.goto('opera:config')
browser.execute_script( 'opera.setPreference("Proxy", "HTTP Server", "127.0.0.1:8888")' )
browser.execute_script( 'opera.setPreference("Proxy", "Use HTTP", "1")' )
should work without restart or anything. The opera:config page itself shows you the options you can set.

Resources