How do I Start My Browser (Firefox) the Way Selenium Does? - firefox

I've got a Selenium test which crashes my browser (Firefox) whenever it runs. It's just a simple test (login, logout, login, logout, login ... crash) and I can't reproduce the crash when I do the same things manually, so I think the problem is with Selenium itself.
However, the issue could be that my Firefox starts with different options than when Selenium starts it. I could confirm that's not the case if I could start Firefox the exact same way Selenium starts it (eg. without plug-ins, with all history cleared, etc.) ... but I'm not sure how to do that.
Can anyone tell me which options to use to make Firefox run the same way as when Selenium runs it?

I was never able to find out how to emulate Selenium's use of Firefox. I tried using a fresh Firefox profile, but that still seemed to have differences from how Selenium ran Firefox.
Instead I wound up re-writing my test to be two tests, and then it was able to log in/out twice in the first test and once in the second test, avoiding the issue I was trying to debug (which only manifests when I try to log in/out 3 times in the same test).
If anyone can provide a better explanation of how to emulate Selenium's running of Firefox I'd be happy to accept that answer.

Related

Why Selenium starts Firefox in safe mode sometimes (without user pressing Shift)?

I am using Firefox Selenium Web Driver to run automatic tests on a dedicated testing machine, so there is nobody pressing Shift there that would cause Firefox to start in the safe mode. But still several times a day Firefox starts with this safe mode dialog:
Any idea what could be causing this behavior?
Multiple tests are running at the same time, so there are several Firefox instances, can they maybe influence each other somehow?
I have disabled automatic safe mode after Firefox crashes as described here, but without success.
The reason is that some of my tests are running external AutoIt script that is "pressing" a Shift key to enter upper case letters. If another test is starting its Firefox at the same moment, Firefox detects the Shift key and displays the Safe Mode dialog.
osdHotkey simple utility that displays and logs pressed keys helped me to find out what is going on.

How to open browsers in private/incognito mode with selenium?

I'm writing Selenium tests in Ruby to test my website in multiple browsers.
However, the tests won't fire correctly unless the cookies are clear(there are triggers I'm testing that only happen X number of times and is stored in a cookie).
Does anyone know how to have selenium open a browser in its private browsing or incognito mode with Selenium or have another idea on how I might solve the issue?
You can get Chrome to start in incognito by default.
There's a solution for Windows at the bottom of the link below... If you're not using Windows, you can Google how to achieve this for you OS =)
https://productforums.google.com/forum/#!topic/chrome/sYaZkNW8II4

Why does Selenium Webdriver start failing tests if I focus off its FireFox window?

I have some SeleniumWebdriver/TestNG tests that Im successfully running on FireFox. If I am watching the tests run, it is okay.
But If I start using another browser in the meanwhile, or skype for example, and I go back to the FireFox window that is running the tests, I always find out that some error has occurred - for example, the "User name" input hasnt been filled out.
Why does this happen, and how can I prevent it?
Try to use driver.switchTo().window(driver.getWindowHandle()); when filling out the form.

PrintWindow works in standalone application and does partially work in NPAPI plugin

I have a code, which captures a given window by PrintWindow function. Specifically I do capture web-pages in a browser. This code is tested in a standalone Windows application, and it works ok. The same code is incorporated into NPAPI plugin and loaded into Google Chrome. There problems happen. If Chrome has only one tab, the code works OK. If Chrome has 2 tabs, the code returns black box of expected size. I tested the standalone application and the plugin at the same moment, on the same window handle (Chrome_RenderWidgetHostHWND). Application does ALWAYS work, the plugin does ALWAYS fail if multiple tabs are open in the browser.
I'd really appreciate, if someone give a clue how to fix this.
Thanks in advance.
NB. Other methods of capturing windows are inapplicable due to even greater shortcomings for my usecase.
I bet you're running into sandboxing issues.
Your app is likely running at the "normal" integrity level, so it has no problem posting the WM_PRINT or WM_PRINTCLIENT message to the Chrome process. (PrintWindow uses these messages under the covers.)
When you're a plugin in Chrome, I believe your code runs as a "low" integrity process (which reduces the chances of things like shatter attacks). Thus it doesn't surprise me that sending the message to a window in another process fails.
Unfortunately, that doesn't explain why it works when Chrome has only one tab. Are you finding the same instance of Chrome_RenderWidgetHostHWND in both the app and the plugin in the case where you have multiple tabs open? In general, there's one of these windows per tab. How are you finding the window?

Why isn't Selenium capturing my keystrokes?

I'm trying out the recorder of the latest Selenium IDE Firefox extension on win32/ff3.
On one page, currently I have to hit Enter to go to the next page, but it's not on a submit button, it's captured manually. This is not picked up by the recorder. I know I can enter it manually myself after recording, but why isn't this part of it?
From the Selenium FAQ:
http://wiki.openqa.org/display/SIDE/FAQ
"Not every event will be recorded by Selenium IDE. Usually the ones that won't be recorded are those that involve complex HTML and/or AJAX. We hope to improve this over time, but there will always be situations where the IDE can't record everything because it has to balance recording too little with too much."
Have you tried with a different browser? Does it happen the same in FF2, IE ?
Use the latest nightly version. I know that there are some problems with FF3.

Resources