Running a Rails test suite with Selenium often opens Firefox with the "Start in Safe Mode?" dialog. Is there a way to either 1) disable this, or 2) add a script that will answer "No" if the dialog appears?
It appears to be related to some open Firefox issues. Please see here:
Disable/Change Firefox Safe Mode Hotkey (Shift)
If you're looking for an alternative to selenium and Firefox, I've had success with PhantomJS (a headless WebKit browser) and the poltergeist gem.
For 1)Disable this:
You can create your own custom profile.
For 2)Add a script to answer 'NO'
Use Autoit to write a script for answering NO and use that in your selenium program.
Related
I'm testing my Rails project and there are some problems when the test is running.
cucumber features/test.feature
I have installed chromedriver for WSL2 and the test can run fine. However, the browser showing up is not rendered at all, it only has a border and transparent body like this.
I can still open google-chrome and it is displayed correctly. And the project used to work on WSL1. I can also take screenshots when testing, it's just that the browser's UI is not rendered.
I have installed the driver for GPU as stated in the WSL guide but the problem still persisted.
Has anyone encountered this problem and how can I fix it? Thank you very much.
I have a file upload control in my UI marked with webkitdirectory. When I upload a folder in the following way, running in non-headless mode, it works:
find('.directory-upload', visible: false).set(Rails.root + "test/data/directory_to_upload")
However, when I run headless (with the :headless_chromium driver) it fails silently, i.e. the code runs but the directory isn't actually selected in the control (so the ensuing form validation fails).
Are there differences in supported HTML between headless and non-headless that could explain this?
You've run into a known bug in headless Chrome - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary - nothing your can really do about it.
When I do js: true test (rspec+capybara+selenium) it runs the browser and all steps are visible. I wish to be able to stop in some point and look around the page. Is there a way to do that? For non js: true tests save_and_open_page from gem launchy works well but here it's useless.
Nothing is better than putting a sleep or a debugger breakpoint where you want to stop, then you can look around the page.
Also note that your browser will be loaded by capybara without extensions, so you cannot use firebug or other tools (but perhaps the native developer tools of firefox remain available I'm not sure)
Sometimes, when running automated tests in PhantomJS using Cucumber for Rails 4, it would be really, really useful to actually sit in front of my screen, look in a window, and see exactly what the browser is doing.
There are times when your code is right and your test is right, but testing fails intermittently nonetheless. It's often because of a script, or an animation, or some CSS that gets in the way. But seeing a screenshot, drilling into a DOM inspector, or using the debugger is not enough to catch those edge cases.
Is there any way to have a window looking at what PhantomJS is doing in the background? It could be something in X Window, or running in a VNC Server, etc. Anything visual would greatly help with debugging, especially in with those finicky details.
I found a little program called PhantomVNC, but it's not telling me much on how it works. It looks like something just feeding a series of screenshots through VNC.
I tried PhantomJS and Capybara-WebKit, but neither of those headless browsers other a "head" option. Selenium-WebDriver seems complicated to set up and only seems to work with a full browser like Firefox, and that may cause more problems than it solves.
If you have any ideas, please let me know. Thank you in advance.
Not sure specifically about Cuc/Rails - but I specifically have a second chrome/webdriver Virtual Machine for this. I use PhantomJS specifically for the headless automatic acceptance testing, but when there is an issue with the tests and I'm trying to diagnose it can be helpful to view the browser live.
In other words, spin up a Ubuntu desktop VM, install chrome, install selenium server and the chrome webdriver. Log in to the VM, open chrome, make sure selenium is running, then configure your test suite to connect to the selenium webdriver service (usually port :4444) of this instance. Run your tests and you should be able to watch the chrome instance on the VM.
It seems a dumb question: I just have to set extensions.yslow.autorun to true, then everything is supposed to work perfectly. But it's not.
When I run the bash script:
URLS=(http://www.google.com http://www.yahoo.com)
for link in "${URLS[#]}";
do
firefox -P YSlow -no-remote $link &
echo $link
PID=$!
sleep 20
kill $PID
done
YSlow doesn't run unless I manually click the YSlow button.
Well, how can I ensure that YSlow does run everytime firefox is started? Anybody have an idea?
Why I want to do this:
I want to monitor several URLs' performance. And a report needs to be written every week, so it would be nice to automate this task.
I did it according to this post:
http://tech.groups.yahoo.com/group/exceptional-performance/message/822
It's frustrating that it doesn't work out when it's supposed to do.
EDIT:
Someone having experience with showslow might help me out. Thank you.
Tools -> Add ons -> Yslow -> Options -> "Automatically run yslow when page finishes loading"
You note that
But when I restart firefox, the process repeats. So I'm not able to automate.
Is the preference extensions.yslow.autorun being saved to your YSlow profile or the default profile? Start up the browser with -P YSlow and check the value of this preference in about:config.
Here is my solution to make yslow autorun when the page once loaded:
First, you might have firebug installed on your firefox, and have your firebug "On for All Web Pages", and you can check the snapshot below (Sorry for the inconvenience, because I cannot upload the image because of my low reputation):
Second, you should turn autorun 'on' for yslow.
In a word, you also have to have your Firebug on all pages and autoron on for Yslow.
I am using Firefox v15.0, Yslow: 3.1.4, Firebug: 1.10.2