can't connect to Selenium server from vagrant machine - django

i built my first web project on a vagrant machine. I would like to run some browser tests with selenium. i have the tests (and rest of project) on virtual machine.
it appears that I can use selenium server standalone to connect to my local machine and run the browsers on the local machine.
On the local machine, I run the following: java -jar selenium-server-standalone-3.8.1.jar
I get a bunch of successful code including: osjs.AbstractConnector:main: Started ServerConnector#709a8be8{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
Presumably, that is where i can connect from my virtual machine.
I then have a small python script:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://0.0.0.0:4444',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get("http://www.python.org")
I get the following error: urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
I can't find much more detail on this process than these steps. If someone could help with this problem, I'd be grateful.

try
driver = webdriver.Remote(
command_executor='http://selenium-hub:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get("https://google.com")

Related

Issues using Selenium in EC2 instance

I'm trying to run a Selenium web scraper in an EC2 istance. I'm pretty new to this so I followed the guide here https://medium.com/#praneeth.jm/running-chromedriver-and-selenium-in-python-on-an-aws-ec2-instance-2fb4ad633bb5
And got chromedriver and google chrome installed. However when I try to run a script that attempts to open chromedriver I get an error, "unknown error: Chrome failed to start: exited abnormally."
There isn't a lot of good information and I have no idea what is causing this.
This is the exact error I am getting.
https://miro.medium.com/max/1400/1*RLSHpS4ZLmnhRcvduEhWXA.png
This test code will show the error if it doesn't work.
import selenium
from selenium import webdriver
print('trying to open webdriver now')
driver = webdriver.Chrome()
driver.get("http://www.stackoverflow.com/")

Strategic error on Python/Flask deploy

I'm new to web development and deployment however I developed a web site using Python 2.7 and Flask. I can't get the site to load when the user hits the site. When testing on the server using SSH the program starts like it did on my development PC but does not render the first template and shows this error: WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
In researching that error I found an article that says Flask is not meant for a multi-user public web environment. Further investigation said: If you want to run Flask in production, be sure to use a production-ready web server like Nginx, and let your app be handled by a WSGI application server like Gunicorn.
I think what this is telling me is:
Find a provider that supports Nginx.
Install Gunicorn and then configure it to run on that host.
Doing that should allow my program to run on the host server and be accessible to the world.
Would folks with experience with Python/Flask web apps please confirm the direction I should be heading as I can't afford to go down the wrong path again.

Selenium server did not start.Another Selenium process may already be running or your java version may be out of date

Just starting out with Polymer and Unit Testing. I was trying out the activity on this page https://www.polymer-project.org/2.0/docs/tools/tests but I couldn't get polymer test to run. So I tried running polymer test --verbose and end up getting this error:
Error: Selenium server did not start.Another Selenium process may already be running or your java version may be out of date.
error: cli runtime exception: Error: Selenium server did not start.Another Selenium process may already be running or your java version may be out of date.
error: Error: Selenium server did not start.Another Selenium process may already be running or your java version may be out of date.
at ChildProcess.errorIfNeverStarted (C:\Users\Eleonor Somosot\AppData\Roaming\npm\node_modules\polymer-cli\node_modules\selenium-standalone\lib\start.js:141:15)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
Hoping someone could help me with this and maybe explain. Thanks..
Hit below url for shut down already running selenium server on port 4444.
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
If selenium server is already running on port 4444 then it will shut down the server and says OK if selenium is not running on this port 4444 then by hitting above url will give you "Unable to connect"
If no server was running, Tuned out the java version was in cause. Make sure you are running java 7 or higher:
java -version

python script to collect the hostname of remote windows server

I have python 2.7 installed on my windows 7 machine.I wrote a script to connect to the remote windows server and it worked fine. Now i want to execute a command on the remote server and collect the hostname.
I know how to collect local machine details but how to collect remote machine info??
Any help would be really appreciated.
here's the script
c = wmi.WMI(self.ip, user=self.username, password=self.password)
Getting OS_Info from remote machine:
import wmi
"" "hostname=remote server ip or domain name"""
conn=wmi.WMI(hostname,user=username,password=password)
for os in conn.Win32_OperatingSystem():
print os
Note:Make sure that your machine is connected to server domain or workgroup
[below links are the best tutorial for WMI]
< http://timgolden.me.uk/python/wmi/cookbook.html>
http://coreygoldberg.blogspot.in/2008/12/python-monitor-windows-remotely-with.html

Django manage.py commands with Google App Engine and Vagrant

I have a Google App Engine app and I'm running Windows with Vagrant. I have an Ubuntu installation which I access via vagrant ssh. On that machine I installed the Google App Engine SDK for Python and I can successfully deploy my app with:
appcfg.py update myapp --oauth2 --noauth_local_webserver
The --noauth_local_parameter allows me to copy the oauth URL and paste in the browser on my Windows machine, because on the Linux machine I have no GUI. Everything is working fine.
But now I want to use the Django manage.py syncdb command, to create the tables in Google Cloud SQL. The problem is, when I execute that command, the text-based w3n browser starts for the authorization, and then I get the error message that the browser does not support javascript.
I'd like to run the manage.py commands with the --noauth_local_webserver flag, but that is not supported by the manage.py commands. How can I solve this? I have already installed an Ubuntu virtual machine with GUI and given the app the permission and manage.py works fine on that machine, but when I try to execute the command on the Vagrant (non GUI) machine, it stills want to open the browser for permission.
Hm, I manually copied the oauth .dat file to the vagrant server, and manage.py syncdb is now working, but the website still can't connect in the browser; it says:
No valid OAuth 2.0 credentials. Before using the Google SQL Service backend on dev_appserver, you must first run "manage.py syncdb" and proceed through the given instructions to fetch an OAuth 2.0 token.
It seems to be the same errors as here. In my case it seemed that the necessary GOOGLE_SQL_OAUTH2_REFRESH_TOKEN environment variable was not set. I copied this refresh token from the .dat file and set it in the app.yaml:
env_variables:
GOOGLE_SQL_OAUTH2_REFRESH_TOKEN: "..."
Now everything is working fine.