Selenium Webdriver http.client.BadStatusLine: ' ' error? - firefox

I am trying to get selenium webdriver to work, but even with a simple python script like this:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.google.com')
driver.quit()
I am getting:
Traceback (most recent call last):
File "test.py", line 14, in <module>
driver.get('http://www.google.com')
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 207, in get
self.execute(Command.GET, {'url': url})
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 193, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 358, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 389, in _request
resp = self._conn.getresponse()
File "C:\Python34\lib\http\client.py", line 1171, in getresponse
response.begin()
File "C:\Python34\lib\http\client.py", line 351, in begin
version, status, reason = self._read_status()
File "C:\Python34\lib\http\client.py", line 321, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: ''
This has been going on with all the scripts I am trying. Firefox will open and attempt to open the website and then close and then another Firefox instance opens up but is a completely new blank page. I am currently on the latest version of everything. Firefox 31.7.0 ESR (up to date according to Firefox), Selenium 2.46.0, and Python 3.4. Any help would be appreciated!
Thanks

Use Firefox stable releases. Version 38 should work.

Related

JupyterLab in Homebrew-installed Anaconda fails to start kernel, looks for old install

I was hoping someone could help me understand why JupyterLab fails to spin up a kernel on my system.
Background
I'm working on macOS High Sierra. I used to have Anaconda installed via the Mac OS installer in the default location in my home folder ($HOME/anaconda). Based on this thread I uninstalled Anaconda.
I reinstalled Anaconda from the Homebrew Cask (placing export PATH=/usr/local/anaconda3/bin:"$PATH" in my .bashrc).
The Problem
Now when I
run jupyter-lab,
create a new notebook, and
select a Python 3 kernel,
the process fails with the following output:
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/web.py", line 1543, in _execute
result = yield result
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/handlers.py", line 73, in post
type=mtype))
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 79, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1107, in run
yielded = self.gen.throw(*exc_info)
File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 92, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 1099, in run
value = future.result()
File "/usr/local/anaconda3/lib/python3.6/site-packages/tornado/gen.py", line 315, in wrapper
yielded = next(result)
File "/usr/local/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py", line 148, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 259, in start_kernel
**kw)
File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/manager.py", line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File "/usr/local/anaconda3/lib/python3.6/site-packages/jupyter_client/launcher.py", line 128, in launch_kernel
proc = Popen(cmd, **kwargs)
File "/usr/local/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '~/anaconda/bin/python': '~/anaconda/bin/python'
I'd already removed all references to $HOME/anaconda (my old install location) from my environment (.bashrc, .bash_profile), so I can't figure out where the reference is being picked up.
Any suggestions would be greatly appreciated.
This question was answered in this GitHub thread for the Jupyter project. The basic solution:
run jupyter kernelspec list to see if it points to the correct Python install
if not, remove the folder ~/Library/Jupyter
re-run jupyter kernelspec list
This should rebuild the directory and give output like
Available kernels:
python3 /usr/local/anaconda3/share/jupyter/kernels/python3
which is the proper location for the Homebrew install of Anaconda.

Behave in parallel

I try to run behave tests in parallel. For this I use behave-parallel lib and demo project https://github.com/vishalm/behave_parallel_demo. But OS is Windows 10. After steps from Read_me file. I am getting next Tracebacks
(behave_parallel_demo-master) D:\Python_projects\behave_parallel_demo-master>behave --processes 5 --parallel-element feature
INFO: 0 scenario(s) and 3 feature(s) queued for consideration by 5 workers. Some may be skipped if the -t option was given...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\python27\Lib\multiprocessing\forking.py", line 381, in main
self = load(from_parent)
File "c:\python27\Lib\pickle.py", line 1384, in load
return Unpickler(file).load()
File "c:\python27\Lib\pickle.py", line 864, in load
dispatch[key](self)
File "c:\python27\Lib\pickle.py", line 1089, in load_newobj
obj = cls.__new__(cls, *args)
TypeError: __new__() takes exactly 3 arguments (2 given)
Traceback (most recent call last):
File "c:\python27\Lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\Andriy_Petrenko\Envs\behave_parallel_demo-master\Scripts\behave.exe\__main__.py", line 9, in <module>
File "c:\users\andriy_petrenko\envs\behave_parallel_demo-master\lib\site-packages\behave\__main__.py", line 111, in main
failed = runner.run()
File "c:\users\andriy_petrenko\envs\behave_parallel_demo-master\lib\site-packages\behave\runner.py", line 561, in run
return self.run_with_paths()
File "c:\users\andriy_petrenko\envs\behave_parallel_demo-master\lib\site-packages\behave\runner.py", line 583, in run_with_paths
return self.run_multiproc()
File "c:\users\andriy_petrenko\envs\behave_parallel_demo-master\lib\site-packages\behave\runner.py", line 690, in run_multiproc
p.start()
File "c:\python27\Lib\multiprocessing\process.py", line 130, in start
self._popen = Popen(self)
File "c:\python27\Lib\multiprocessing\forking.py", line 280, in __init__
to_child.close()
IOError: [Errno 22] Invalid argument
What I do wrong or is this OS problem? It looks like that 5 workers were up but 1st problem is that TypeError: __new__() takes exactly 3 arguments (2 given) and 2nd IOError: [Errno 22] Invalid argument
I am not familiar with Behave so not sure whether you are passing the command line correctly but this error means that one of the method is expecting more arguments than you have provided. In this case, it's during creation of cls instance:
File "c:\python27\Lib\pickle.py", line 1089, in load_newobj
obj = cls.__new__(cls, *args)
This looks like some internal class instance so you do not control it directly so make sure you pass enough and correct arguments at command line.
Update your Behave package. it will work.
We have been trying for a long time to implement parallel test executions with behave (which is an amazing framework). Finally, we created our own wrapper on top of Behave, called BehaveX, that not only allow us to execute tests in parallel, but also comes with great reports and some additional features:
https://github.com/hrcorval/behavex
As BehaveX is implemented over the Behave framework, with this wrapper you should be able to replace the "behave" executable by "behavex", and run the tests in parallel using the following commands:
behavex -t #TAG --parallel-processes 4 --parallel-scheme scenario
behavex -t #TAG --parallel-processes 3 --parallel-scheme feature

Julia Kernel Error in Jupyter Notebook (Anaconda)

When I open a Julia 0.6.0 notebook using Jupyter, the kernel tries to connect, fails and the a red button "Kernel Error" appears at the top right of the notebook. I uninstalled and reinstalled, but nothing has changed. The following is the message I got when I click on the "Kernel error":
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\base\handlers.py", line 516, in wrapper
result = yield gen.maybe_future(method(self, *args, **kwargs))
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 1055, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\concurrent.py", line 238, in result
raise_exc_info(self._exc_info)
File "<string>", line 4, in raise_exc_info
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 1063, in run
yielded = self.gen.throw(*exc_info)
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 75, in post
type=mtype))
File "C:\ProgramData\Anaconda3\lib\site-packages\tornado\gen.py", line 1055, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 990, in _execute_child
startupinfo)
OSError: [WinError 740] The requested operation requires elevation.
Thanks in advance for your help!
It seem like you do not have enough permissions to start the Julia Kernel.
You should not need to be administrator to use the Julia kernel, but it seem like your computer is believing you should.
Try running the julia interpreter, and kernel manually to see if you can.

Error in browser console "DEPRECATED: The widget module is deprecated. Please consider using the sdk/ui module instead."

I am using addon-sdk for developing an extension.When I ran my code using cfx run on Firefox 32.0 and checked the browser console it shows following:
"DEPRECATED: The widget module is deprecated. Please consider using the sdk/ui module instead.
Traceback (most recent call last):
File "resource://gre/modules/commonjs/sdk/addon/runner.js", line 114, in startup/<
run(options);
File "resource://gre/modules/commonjs/sdk/addon/runner.js", line 170, in run
let program = main(options.loader, options.main);
File "resource://gre/modules/commonjs/toolkit/loader.js", line 645, in main
return loader.load(loader, module).exports;
File "resource://gre/modules/commonjs/sdk/loader/cuddlefish.js", line 129, in CuddlefishLoader/options<.load
result = load(loader, module);
File "resource://gre/modules/commonjs/toolkit/loader.js", line 299, in load
evaluate(sandbox, module.uri);
File "resource://gre/modules/commonjs/toolkit/loader.js", line 262, in evaluate
: loadSubScript(uri, sandbox, encoding);
File "resource://skype_ff_extension-at-jetpack/skype_ff_extension/lib/main.js", line 14, in null
var widgets = require("sdk/widget");
File "resource://gre/modules/commonjs/toolkit/loader.js", line 619, in require
freeze(load(loader, module));
File "resource://gre/modules/commonjs/sdk/loader/cuddlefish.js", line 129, in CuddlefishLoader/options<.load
result = load(loader, module);
File "resource://gre/modules/commonjs/toolkit/loader.js", line 299, in load
evaluate(sandbox, module.uri);
File "resource://gre/modules/commonjs/toolkit/loader.js", line 262, in evaluate
: loadSubScript(uri, sandbox, encoding);
File "resource://gre/modules/commonjs/sdk/widget.js", line 60, in null
"The widget module is deprecated. " +
File "resource://gre/modules/commonjs/sdk/util/deprecate.js", line 18, in deprecateUsage
let stack = get().slice(2);"
How to debug this error?
PS:To anyone who see this error first check if its your add-on or any other add-on which is throwing this error.
open about:support
then search there Skype Click to Call plugin ID
and remove file with name
{82AF8DCA-6DE9-405D-BD5E-43525BDAD38A}.xpi
from your
mozilla_installation_path\browser\extensions\
(c:\Program Files (x86)\Mozilla Firefox\browser\extensions\)
Solution is to edit code in the add-on. Take out that require('widget') and move to require('sdk/ui'): https://blog.mozilla.org/addons/2014/03/13/new-add-on-sdk-australis-ui-features-in-firefox-29/
Once you change to sdk/ui, you have to change how the add-on was making widgets to use the sdk/ui. Lean about that by:
See and follow the links in the note "Deprecated" seen on the documentation page of widget module: https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/widget
Try removing extensions.sdk.console.logLevel; all from about:config and replacing it with extensions.YOUR_EXTENSION_ID.sdk.console.logLevel; all
This should return the log level to the default of error, meaning you won't see any other extensions' console.log output.
Edit
The above still shows other extensions' error messages, if you want to remove them, do the following.
Check out this post for an explanation. Essentially, you add a string to about:config (by right-clicking) called extensions.sdk.console.logLevel and set it to off, then add the string extensions.YOUR_EXTENSION_ID.sdk.console.logLevel and set it to all.

Using windows command line to run python script with passing of url argument

I am writing this Python program which extracts some information from a webpage and I am required to run it using the windows command line. But I could not even print the original html page as a string. I am using Python 2.7
Here is my Python script:
#sys.py
import sys
import urllib
url = sys.argv[1]
f = urllib.urlopen(url)
print f.read()
When I try to run it from windows command line with: C...>sys.py "www.marinetraffic.com/ais/shipdetails.aspx?mmsi=311389000"
Errors appear as follows:
Traceback(most recent call last):
File "C:\...\sys.py", line 14 in <module>
f = urllib.urlopen(url)
File "C:\Python27\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Python27\lib\urllib.py", line 208, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 463, in open_file
return self.open_local_file(url)
File "C:\Python27\lib\urllib.py", line 87, in open_loca_file
raise IOError(e.errno, e.strerror, e.filename)
IOError: [Errno 2] The system cannot find the path specified: 'www.marinetraffic.com\\ais\\shipdetails.aspx?mmsi=311389000'
There should not be any problem with the Python set up under the windows environment because I can still print out the sys.argv list as the arguments are passed in the command line.
Is it the problem with the 'urllib' library?
Is there any another way to run this using windows command line?
I think the problem is the way you specify your url, it needs to have the http:// part at the start.
It works for me when I type
python sys.py http://www.google.com/
but fails with
python sys.py www.google.com
(Note that I am using linux with python 2.7 but I think it may be the same problem for you)

Resources