How can I ensure YSlow run automatically when firefox is started? - yslow

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

Related

How to stop browserlink.js and aspnet-core-browser-refresh

Why do I have all this junk in my console, only when using VS 2022?
I set Options -> Projects and Solutions -> ASP.NET Core -> Auto build and refresh options -> NONE
And also disabled 'browser link' here:
None of that stuff appears when running the same project in VS 2019, and I'm pretty sure its messing with my SignalR connections
For anyone using dotnet cli tool and want to disable the hot reload and console output whatever, and have no luck with dotnet watch --no-hot-reload, try put this at the very start of your js script:
function removeDotnetHotReload() {
const scriptInjectedSentinel = '_dotnet_watch_ws_injected'
// #ts-ignore
window[scriptInjectedSentinel] = true
}
removeDotnetHotReload()
For aspnet-core-browser-refresh, can you please file an issue at https://github.com/dotnet/sdk, as that's where that code lives?
For Browser Link, I can tell you that right now there's no way to disable those messages in a .NET 6 app without turning off CSS Hot Reload as well (you can turn verbose messages off in the console so they won't show, but they'll still be emitted). If you are ok turning off CSS Hot Reload, you can do that in Tools->Options->Projects and Solutions->ASP.NET Core. Please file feedback at Developer Community about this as well so we can potentially make this more discoverable.
That said, I'm curious why you think this might be interfering with your SignalR connections. If there is interference there, we definitely want to address that as well, but I'm not sure off the top of my head why that would be.
Per https://developercommunity.visualstudio.com/t/Browser-Link-cannot-be-disabled/1582653#T-N1608441, adding "hotReloadEnabled": false to your launchSettings.json profile(s) should suppress the injection of these scripts by Visual Studio. This does not actually turn off C# hot reloading - just turns off the scripts that MSFT injects.

Can I see what happens in PhantomJS?

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.

How to prevent Firefox from starting in safe mode?

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.

how can I stop my server from freezing when powershell is in 'select' mode?

I didn't believe this until I tested it a few times, but it's really happening.
Start rails server and app from powershell: 'rails s'
open a web page from that server
note how long the page took to get served up
now in powershell, select some text
reload the webpage from step 2
note that the webpage is taking forever to load
set up the windows so that you can see the powershell window and web page at the same time
go back to powershell and hit 'Enter' (so that the selected text is copied)
note that the web page loads as soon as the powershell window leaves select mode
TLDR: Rails server started via powershell won't serve pages while powershell is in 'Select' mode.
Is there some setting in powershell that will stop it from doing this? I can see it being helpful when selecting text in the middle of a bat run but when it stops my server it's flipping obnoxious.
Open a powershell window that you would normally start rails in. Open the properties dialog for the window and deselect QuickEdit Mode on the Options tab.
I had commented thinking it was just a general issue with the console system, and it probably still is as I cannot see how powershell is involved here as it's just a parent process, but it appears to be isolated to code that is watching for input. I think the rails server might be looking for input during its main loop, and perhaps selecting text in the console is blocking this. Take this simple script that loops - but does not watch for input - on a single thread, writing to a debug listener:
ps> $i = 0
ps> while (1) { sleep -seconds 1; [diagnostics.trace]::writeline("ping: $i"); $i++ }
Now, run sysinternals/microsoft's free DbgView tool to watch the output. I am using a separate tool instead of writing to the console because this is more like your scenario where web pages are being served in the background to a socket. You can get DbgView from:
http://technet.microsoft.com/en-us/sysinternals/bb896647
When I select the text in the console, the script does not pause. I even stuffed in a check in the key buffer, and it still did not stop.
I think the Rails server is doing some kind of key checking which is being blocked somehow and interfering with its ability to process requests. It seems retarded, but my script doesn't fail even if I stuff in a check for [console]::keyavailable
ps> while (1) {
>> sleep -seconds 1;
>> [diagnostics.trace]::writeline("ping: $i");
>> $i++
>> $dummy = [console]::keyavailable
>> }
Looks like it's Rail's fault, albeit unintentionally of course.

Testing multiple concurrent browser sessions

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.
When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.
Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?
Edit: To clarify, I'm not yet at the stage where I want to run automated tests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.
You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name". You can run as many instances of Firefox as you want, and each one runs with an independent profile and thus independent session.
Automate it!
You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would help you..
easy.cookiejar = "cookiejar.file" => "pwd string"
Set a cookiejar file to use for this Curl::Easy instance.
This file will be used to persist cookies.
Use http://watir.com/ to create ruby scripts exercising your game.
Use multiple Watir::Browser instances to run multiple browsers.
Use firefox' profiles and -no-remote switch to keep them separated. See also this question.
Rather than opening a new tab, create a new window in your Web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I haven't tested it in the WebKit based browsers.

Resources