Rails how to automatic check if a link is broken? - ruby-on-rails

How is it possible to automatic check if a link is broken?
What is the best solution (Screenscraping or other)

You could try selenium which is an automated testing framework.
You could also try monit which is a monitoring application (daemon). Sometimes I just use that service to check if a particular website or link is up. You can set it to check periodically.

Related

unable to execute karate script in Firefox webdriver docker container [duplicate]

I would like to understand if,
- it makes sense to have Karate integration with SauceLabs
- Benefits if that is an Yes
Also, if i want to implement the integration what is the approach i should use.
I am planning to mimic the similar implementation using Selenium remote web driver. Please let me know if this is the only approach that can be taken or there is any other way out for this.
Yes, if SauceLabs conforms to the spec - refer to the documentation for webDriverSession: https://github.com/intuit/karate/tree/master/karate-core#webdriversession
Note that this has been proven to work with Zalenium: https://github.com/intuit/karate/tree/master/karate-core#webdriverurl
And also AWS Device Farm: https://twitter.com/ptrthomas/status/1222790566598991873
Please note that if you are ok to use only Chrome, the Docker approach may give you a better experience, but you can decide: https://github.com/intuit/karate/tree/master/karate-core#karate-chrome
EDIT - also see:
https://stackoverflow.com/a/64682293/143475
https://stackoverflow.com/a/63270092/143475
https://stackoverflow.com/a/65644566/143475

How to avoid "automation server can't create object" without changing the browser security settings?

Recently I got the error "automation server can't create object", for which I know the solution is to add your website to trusted sites and enable the setting: "Initialize and script ActiveX controls not marked as safe for scripting". But since this is a security issue, I searched for an alternative workaround but came up with nothing.
So, I am wondering if there is any other work around for this?
Please look at this SO question. Check if you did everything that was discussed there.
The first thing is to implement IObjectSafety interface. Then sign the activex and installer and CAB. You might also want to look at this example how to implement an activex.

Is it possible to do ruby-debug on a remote server?

I'm trying to debug a remote server.
How would I perform ruby-debug and access the console through breakpoints?
Is that possible to do and click through the site to activate those breakpoints?
ruby-debug has had out-of-process debugging for a long while. In fact the code mentioned in that Noufal Ibrahim cites, is using the same underlying common code.
However I've just added some documentation describing how it works in the reference manual.
See http://bashdb.sourceforge.net/ruby-debug.html#Remote-Debugging and http://bashdb.sourceforge.net/ruby-debug.html#Out_002dof_002dprocess-execution-options
If you can ssh to the server, you're probably better of running your debugger locally over there.
Otherwise, you might want to take a look at http://blogs.oracle.com/martink/entry/remote_debugging_debug_whatever_ruby.

Click-once for services?

I have an app that runs as a service, and I'd like it to be able to check a URL to see if a new version is available, and if so to download and install it. I can manually hack something together, but would be great if I could create an MSI package to update the service, and any other components that are part of my distribution. I'd also like it to be done without any UI, so the user is unaware of the update.
Are there any good solutions for this?
This could be tricky depending on what your update might want to do.
If you intend on deleting and re-installing the service, this may require a reboot, which will certainly be visible to the user.
In order to replace the components of the service, the service has to be stopped first. If your service itself is detecting the update availability, it may have to kick off another process to stop the service, run the installer/updater and then restart the service.
Try installer.codeeffects.com. It has this feature.
You could try MEF (http://www.codeplex.com/MEF) and use
[Import("http://someUrl/someComponent")]
public ISomeComponent SomeService;
Its not actually an auto update, but the service could be always up to date. I am not sure if it works.. its just an idea :-)

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