Web browser not opening using Watir - ruby-on-rails

I'm trying to open my browser using Watir with Ruby. I was able to run my script and open the browser once. Now I'm getting the error:
#<Watir::Browser:0x586947ae595497d2 url="data:," title="">
Title should be equal to "data." Chrome will open and then close without actually traveling to a webpage.
These were my steps after installing watir and chromedriver
1) rails c. 2) browser = Watir::Browser.new(:chrome)
I'm following a tutorial: https://youtu.be/1UYBAn69Qrk?t=4m24s
Any help would be greatly appreciated!

Silly mistake on my part, chromedriver wasn't properly installed. I came across this post. Here are the steps I took:
$ cd $HOME/Downloads
$ wget http://chromedriver.storage.googleapis.com/2.20/chromedriver_mac32.zip
$ unzip chromedriver_mac32.zip
$ mkdir -p $HOME/bin
$ mv chromedriver $HOME/bin
$ echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile

Related

Anydesk installation by bash script using wget

I'm trying to write a bash script for automating the installation of anydesk by wget with the help of the following code:
echo -e "[ - ] Installing AnyDesk..."
wget --max-redirect 1 --trust-server-names 'https://anydesk.com/en/downloads/thank-you?dv=deb_64' -O anydesk.deb
sudo apt install ./anydesk.deb
echo -e "[ ✔ ] AnyDesk ➜ INSTALLED\n"
The problem is that https://anydesk.com/en/downloads/thank-you?dv=deb_64 returns a HTML page, not a Debian package.
How can I parse the HTML page to find the download link to the Debian package?
I examined page source of https://anydesk.com/en/downloads/thank-you?dv=deb_64 and download is triggered by JavaScript depending on User-Agent of browser, wget does not support JavaScript execution therefore you are actually getting HTML page source not actual .deb file. Use tool which support JavaScript execution to get actual file.
You can run the following command:
wget -O anydesk.deb https://download.anydesk.com/linux/anydesk_6.2.1-1_amd64.deb
this will allow you to download Anydesk, via wget.

Sheduling start rails server after rebot with .sh script "script.sh: line 2: rails: command not found" error

I tried to automatically run my Rails server after a server reboot. I use cronetab that refers to file with scripts.
I have a problem with file.sh execution.
In this file I
#!/bin/bash
cd MyApp/ && rails s
redirect to app folder and try to run command to run the server.
I try to do a test run by launch script from bash
/directory/to/script/file.sh
but all i got is
/directory/to/script/file.sh: line 2: rails: command not found
When I run cd MyApp/ && rails s in bash directly everything works just fine.
Can you please help me. I need to automate starting rails server after rebooting.
System => Ubuntu Server 18.04.2 LTS
Thank you, guys.
In the end, the answer was already on Stack "Start rails server automatically when ever I start my ubuntu machine" but not the best-score answer was right :)
I dump idea with external script and pack everything to crontab
#reboot /bin/bash -l -c 'cd /full/path/MyApp && rails s'

How to install Ngrok 2.0 on linux subsystem on Windows 10

I am trying to use Ngrok to create an introspected tunnel to localhost webhook development tool on my Linux subsystem (Powershell --> bash)
I try to install ngrok using the following:
sudo apt install ngrok-client
From what I understand the sudo command used installs ngrok v 1.6.
When I attempt to execute ngrok 80 I get an error:
Invalid address server_addr 'ngrokd.ngrok.com:443'
I searched for this in another post and was informed that ngrok v. 1.6 is obsolete and in order to continue using ngrok would be to upgrade to 2.0
Testing PayPal with Rails
It's advised to download from the website http://ngrok.com, which is simple enough, but what is the correct way to download for linux subsystem use? Should I download for Linux and unzip? Or am I suppose to download for Windows?
Let me know if I'm misunderstanding anything
I use ubuntu since years, I trust the online instructions so either do:
sudo apt-get update
sudo apt-get install ngrok-client
or try to use this instruction and let me know if you have problems
the same instructions are included hear
$ unzip /path/to/ngrok.zip
$ is just the sign from your terminal. You do not need to input $, but you need to open the terminal (ctrl+alt+t), run the unzip command to unzip the folder.
You will find the folder under your downloads. So / is the root of your machine. You need to go inside your home folder which will be /home so you do cd (change directory) followed by that path
cd /home
then you do ls to list all the directories. You should see your profile with your name username. You should be able to get in the download folder with cd <username>/Downloads where <username> should be replaced with your personal folder name
At this point you are inside the Downloads directory. You can do an ls in your terminal, find the name of the file you downloaded (should be something like ngrok-stable-linux-amd64.zip) and run
unzip <file-name.zip>
where file name is the file you downloaded (something like ngrok-stable-linux-amd64.zip) or you can go back to the root directory and run
cd /
unzip /home/<username>/Downloads/<yourfile.zip>
Read the documentation on how to use ngrok. Try it out by running it from the command line:
./ngrok help
Also I read from the documentation, that you can set up that address
There is some discussion online about this
Testing PayPal with Rails
I can help you more but I need your feedback
You can try this from the official docs.
sudo tar xvzf ~/Downloads/ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin

Trying to create symlink - keep getting error: "File exists"

I am trying to use Pow and create a symlink so that I can ultimately run my rails application locally at the following URL:
http://market_place_api.dev/
I am going through the API's on Rails tutorial, and when I follow the author's instructions on setting up Pow and a symlink, here is what is happening:
cd into a folder called "code", and created a new rails app: $ rails new market_place_api -T
Installed Pow: $ curl get.pow.cx | sh
Gone to the Pow directory: $ cd ~/.pow
And here is where the problem occurs. The instructions say to symlink: $ ln -s /path/to/myapp
In my case, the app is located at this URL: /Users/harrylevine/Dropbox/Coding/BLOC/code/market_place_api
So I enter into the command line: $ ln -s /Users/harrylevine/Dropbox/Coding/BLOC/code/market_place_api and I keep getting this error: ln: ./market_place_api: File exists
I have tried many variations of this, including:
applying this format: ln -s target_path link_path
All to no avail.
How can I properly create this symlink so that I can ultimately run my rails application locally at the following URL:
http://market_place_api.dev/
Thank you.
The error means that there is already a file (or a sym-link) called market_place_api in that directory (~/.pow).
Check with $ ls -l to see what the file is. If it's the correct sym-link then you are ready to proceed with the tutorial.

Automatically Run Command Upon Opening Terminal (Linux Mint 16)

I am using Rails and for some reason unbeknownst to me I have to execute the following line every time I start the terminal in order to use ruby and rails.
source ~/.bash_profile
If I type the following before running the above command, it will recommend that I install the packages (ie "type 'sudo apt-get install package' to install")
rails -v && ruby -v && irb -v
Is there a way to make my terminal execute a command upon opening? Or, better yet, can anybody help explain the reason I have to run this line? I found an article that said I had to do that given my issue but it didn't explain why.
Assuming you're using the bash shell, then ~/.bash_profile will be sourced once (and only once) when you log in to the system but not each time you open a terminal window.
The ~/.bashrc, however, will be sourced every time a new shell is opened (i.e. when you open a terminal window).
So they are probably some environment variables settings in ~/.bash_profile which are required for ruby to run. Those settings should be moved to the ~/.bashrc file instead so they are defined in all shell instances.
Alternatively, source ~/.bash_profile from your ~/.bashrc (this is at your own risk, it may have side-effects).

Resources