selenium: Uploading a large file using send_keys using python - selenium

I am trying to use Selenium to upload a 960KB file on the machine that's running the browser interaction using send_keys, the file is being sent to a different machine. Currently this is not working and I get the following traceback below. However it works when an image or small zipped file is being uploaded (so I don't think it's a problem with uploading a zipped file which is what others have had issues with). I tried to search topics before posting:
https://groups.google.com/forum/#!msg/selenium-users/dlxoowrZYeA/24kPjqRW2FcJ[1-25]
http://grokbase.com/t/gg/selenium-developer-activity/124tpkyzmq/issue-3812-in-selenium-python-cannot-upload-a-file
However after making the suggested edits, it still is not working. I am using selenium 2.25.0, a centos 6.3 operating system and Python 2.6.6
Traceback (most recent call last):
File "/home/testrunner/Suite/CATS/cobalt/cobalttest.py", line 270, in run
testMethod()
File "/home/testrunner/Suite/CATS/mhetest/psmBaseSetupModule.py", line 549, in runTest
PSM.command().find_element_by_name( 'location' ).send_keys( 'filename.tar.gz' )
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 144, in send_keys
value = self._upload(local_file)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 228, in _upload
{'file': base64.encodestring(fp.getvalue())})['value']
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webelement.py", line 205, in _execute
return self._parent.execute(command, params)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 283, in execute
return self._request(url, method=command_info[0], data=data)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 324, in _request
response = opener.open(request)
File "/usr/lib/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1190, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.6/urllib2.py", line 1163, in do_open
r = h.getresponse()
File "/usr/lib/python2.6/httplib.py", line 990, in getresponse
response.begin()
File "/usr/lib/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
**raise BadStatusLine(line)
BadStatusLine**

The issue is resolved when downgrading Firefox to Firefox 5. I am unsure how to upload the file with a more recent version of Firefox.

Related

Error with fetching chromium with fetch command

When I try to fetch chromium with the command it gives me a whole bunch of errors and at the end says "FileNotFoundError: [WinError 2] The system cannot find the file specified"
After the error occurred (output bellow) I tried to add the DEPOT_TOOLS_WIN_TOOLCHAIN to the system environment variables but after a restart nothing happened. Does anyone have a solution to this?
Error Output:
[0:00:00] Started.
Traceback (most recent call last):
File "C:\src\depot_tools\metrics.py", line 301, in print_notice_and_exit
yield
File "C:\src\depot_tools\gclient.py", line 3495, in <module>
sys.exit(main(sys.argv[1:]))
File "C:\src\depot_tools\gclient.py", line 3481, in main
return dispatcher.execute(OptionParser(), argv)
File "C:\src\depot_tools\subcommand.py", line 252, in execute
return command(parser, args[1:])
File "C:\src\depot_tools\gclient.py", line 3032, in CMDsync
ret = client.RunOnDeps('update', args)
File "C:\src\depot_tools\gclient.py", line 2026, in RunOnDeps
work_queue.flush(revision_overrides,
File "C:\src\depot_tools\gclient_utils.py", line 1016, in flush
reraise(e[0], e[1], e[2])
File "C:\src\depot_tools\gclient_utils.py", line 70, in reraise
raise value
File "C:\src\depot_tools\gclient_utils.py", line 1093, in run
self.item.run(*self.args, **self.kwargs)
File "C:\src\depot_tools\gclient.py", line 1005, in run
self._got_revision = self._used_scm.RunCommand(command, options, args,
File "C:\src\depot_tools\gclient_scm.py", line 128, in RunCommand
return getattr(self, command)(options, args, file_list)
File "C:\src\depot_tools\gclient_scm.py", line 610, in update
mirror = self._GetMirror(url, options, revision, revision_ref)
File "C:\src\depot_tools\gclient_scm.py", line 1060, in _GetMirror
if not self.cache_dir:
File "C:\src\depot_tools\gclient_scm.py", line 225, in cache_dir
return git_cache.Mirror.GetCachePath()
File "C:\src\depot_tools\git_cache.py", line 193, in GetCachePath
cachepath = subprocess.check_output(
File "C:\src\depot_tools\.cipd_bin\3.8\bin\Lib\subprocess.py", line 415, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\src\depot_tools\.cipd_bin\3.8\bin\Lib\subprocess.py", line 493, in run
with Popen(*popenargs, **kwargs) as process:
File "C:\src\depot_tools\.cipd_bin\3.8\bin\Lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\src\depot_tools\.cipd_bin\3.8\bin\Lib\subprocess.py", line 1311, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Subprocess failed with return code 1.
You should delete config DEPOT_TOOLS_UPDATE on environment.

fetch chromium - No such file or directory

I've cloned depot tools given instructions from here on ubuntu 17.04.
When I run fetch chromium I get the following error.
./fetch chromium
Running: gclient root
Traceback (most recent call last):
File "./fetch.py", line 299, in <module>
sys.exit(main())
File "./fetch.py", line 294, in main
return run(options, spec, root)
File "./fetch.py", line 280, in run
if not options.force and checkout.exists():
File "./fetch.py", line 82, in exists
gclient_root = self.run_gclient('root').strip()
File "./fetch.py", line 78, in run_gclient
return self.run(cmd_prefix + cmd, **kwargs)
File "./fetch.py", line 68, in run
return subprocess.check_output(cmd, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1024, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I have come across similar errors in stackoverflow while searching for a resolution however none of them helped resolve the problem.
I'm not clear on if there is any steps required after cloning to install depot tools? The readme
Any thoughts on what is required to solve the problem?
Conteh

Socket error when connect to Google Big Query in my local PC

It was working fine for me to run following steps in past two days to connect to Big query in pycharm in my PC
step 1:gcloud auth application-default login
step 2 :then connect to BG in the Pycharm in my local PC.
however, when I used the same method to try today:
Below error occurs:
Since I am behind "Great Wall" in China, so can only use VPN to login in google cloud, so I am not sure if it is caused by the VPN or does it have something to do with the setting of my google'account ? however, I tried with "service-account-key", it happen to be the same issue log:
Traceback (most recent call last):
File "C:/Users/emma/PycharmProjects/GCP/INIT.py", line 134, in <module>
explicit()
File "C:/Users/emma/PycharmProjects/GCP/INIT.py", line 54, in explicit
for dataset in bigquery_client.list_datasets():
File "C:\Python27\lib\site-packages\google\cloud\iterator.py", line 218, in _items_iter
for page in self._page_iter(increment=False):
File "C:\Python27\lib\site-packages\google\cloud\iterator.py", line 247, in _page_iter
page = self._next_page()
File "C:\Python27\lib\site-packages\google\cloud\iterator.py", line 347, in _next_page
response = self._get_next_page_response()
File "C:\Python27\lib\site-packages\google\cloud\iterator.py", line 396, in _get_next_page_response
query_params=params)
File "C:\Python27\lib\site-packages\google\cloud\_http.py", line 299, in api_request
headers=headers, target_object=_target_object)
File "C:\Python27\lib\site-packages\google\cloud\_http.py", line 193, in _make_request
return self._do_request(method, url, headers, data, target_object)
File "C:\Python27\lib\site-packages\google\cloud\_http.py", line 223, in _do_request
body=data)
File "C:\Python27\lib\site-packages\google_auth_httplib2.py", line 187, in request
self._request, method, uri, request_headers)
File "C:\Python27\lib\site-packages\google\auth\credentials.py", line 121, in before_request
self.refresh(request)
File "C:\Python27\lib\site-packages\google\oauth2\service_account.py", line 310, in refresh
request, self._token_uri, assertion)
File "C:\Python27\lib\site-packages\google\oauth2\_client.py", line 143, in jwt_grant
response_data = _token_endpoint_request(request, token_uri, body)
File "C:\Python27\lib\site-packages\google\oauth2\_client.py", line 104, in _token_endpoint_request
method='POST', url=token_uri, headers=headers, body=body)
File "C:\Python27\lib\site-packages\google_auth_httplib2.py", line 116, in __call__
url, method=method, body=body, headers=headers, **kwargs)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1609, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1351, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1272, in _conn_request
conn.connect()
File "C:\Python27\lib\site-packages\httplib2\__init__.py", line 1075, in connect
raise socket.error, msg
socket.error: [Errno 10060]
I update the python-cloud library, then everything works fine now.
Hope it keep it all the time :(

lxml/pyquery: parse in a less strict way

I am using PyQuery to process a large amount of documents from the Web. PyQuery uses lxml to parse the HTML documents.
As a matter of fact, a lot of the documents are not valid HTML. As a consequence, those invalid documents cannot be successfully parsed by lxml, which prevents me from getting the information further. And the the following exceptions are raised quite often:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 1201, in mainLoop
self.runUntilCurrent()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 824, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 382, in callback
self._startRunCallbacks(result)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 490, in _startRunCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 577, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/home/hxiao/hiit/crawl/crawl/spiders/basic.py", line 40, in parse
doc = pq(response.body)
File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 226, in __init__
elements = fromstring(context, self.parser)
File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 70, in fromstring
result = getattr(lxml.html, meth)(context)
File "/usr/local/lib/python2.7/dist-packages/lxml/html/__init__.py", line 706, in fromstring
doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
File "/usr/local/lib/python2.7/dist-packages/lxml/html/__init__.py", line 600, in document_fromstring
value = etree.fromstring(html, parser, **kw)
File "lxml.etree.pyx", line 3032, in lxml.etree.fromstring (src/lxml/lxml.etree.c:68121)
File "parser.pxi", line 1786, in lxml.etree._parseMemoryDocument (src/lxml/lxml.etree.c:102470)
File "parser.pxi", line 1674, in lxml.etree._parseDoc (src/lxml/lxml.etree.c:101299)
File "parser.pxi", line 1074, in lxml.etree._BaseParser._parseDoc (src/lxml/lxml.etree.c:96481)
File "parser.pxi", line 582, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:91290)
File "parser.pxi", line 683, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:92476)
File "parser.pxi", line 631, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:91904)
lxml.etree.XMLSyntaxError: line 649: htmlParseEntityRef: expecting ';'
What I am asking:
I would like a way to let lxml to parse in a less strict way so that this invalidity can be ignored.
This answer may not be very helpful, but I investigated similar problem.
Maybe you can have a look at this tip of pyquery ?
http://pythonhosted.org/pyquery/tips.html

After OpenERP 7 upgrade "ERROR: relation "ir_model_constraint" does not exist"

I'd been using OpenERP 6 OK and decided to upgrade to version 7.
I downloaded openerp_7.0alpha-20121206-000102-1_all.deb from http://nightly.openerp.com/trunk/nightly/deb/ and installed it. Now when I browse to http://localhost:8069 I can no longer select the database (because when there is one DB there is no reason to show the selector,) and after log in I get:
OpenERP Server Error
Client Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/addons/web/http.py", line 195, in dispatch
response["result"] = method(self, **self.params)
File "/usr/lib/pymodules/python2.7/openerp/addons/web/controllers/main.py", line 833, in authenticate
req.session.authenticate(db, login, password, env)
File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 113, in authenticate
uid = self.proxy('common').authenticate(db, login, password, env)
File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 28, in proxy_method
result = self.session.send(self.service_name, method, *args)
File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 101, in send
raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)
Server Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/addons/web/session.py", line 87, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/lib/pymodules/python2.7/openerp/netsvc.py", line 361, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 413, in dispatch
return fn(*params)
File "/usr/lib/pymodules/python2.7/openerp/service/web_services.py", line 424, in exp_authenticate
res_users = pooler.get_pool(db).get('res.users')
File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 50, in get_pool
return get_db_and_pool(db_name, force_demo, status, update_module)[1]
File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 33, in get_db_and_pool
registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs)
File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 156, in get
update_module, pooljobs)
File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 178, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 296, in load_modules
loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 164, in load_module_graph
init_module_models(cr, package.name, models)
File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 373, in init_module_models
result = obj._auto_init(cr, {'module': module_name})
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3211, in _auto_init
self._add_sql_constraints(cr)
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3350, in _add_sql_constraints
self._save_constraint(cr, conname, 'u')
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 2859, in _save_constraint
""", (constraint_name, self._module))
File "/usr/lib/pymodules/python2.7/openerp/sql_db.py", line 162, in wrapper
return f(self, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/openerp/sql_db.py", line 227, in execute
res = self._obj.execute(query, params)
ProgrammingError: relation "ir_model_constraint" does not exist
LINE 2: SELECT 1 FROM ir_model_constraint, ir_module_mod...
^
So I try to run it manually like:
sudo openerp-server stop
su - openerp
openerp-server -d openerp1 -u all
and I get
2012-12-07 07:00:43,417 7584 ERROR openerp1 openerp: Failed to initialize database `openerp1`.
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/openerp/cli/server.py", line 97, in preload_registry
db, registry = openerp.pooler.get_db_and_pool(dbname, update_module=openerp.tools.config['init'] or openerp.tools.config['update'], pooljobs=False)
File "/usr/lib/pymodules/python2.7/openerp/pooler.py", line 33, in get_db_and_pool
registry = RegistryManager.get(db_name, force_demo, status, update_module, pooljobs)
File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 156, in get
update_module, pooljobs)
File "/usr/lib/pymodules/python2.7/openerp/modules/registry.py", line 178, in new
openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 296, in load_modules
loaded_modules, processed_modules = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
File "/usr/lib/pymodules/python2.7/openerp/modules/loading.py", line 164, in load_module_graph
init_module_models(cr, package.name, models)
File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 373, in init_module_models
result = obj._auto_init(cr, {'module': module_name})
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3211, in _auto_init
self._add_sql_constraints(cr)
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 3350, in _add_sql_constraints
self._save_constraint(cr, conname, 'u')
File "/usr/lib/pymodules/python2.7/openerp/osv/orm.py", line 2859, in _save_constraint
""", (constraint_name, self._module))
File "/usr/lib/pymodules/python2.7/openerp/sql_db.py", line 162, in wrapper
return f(self, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/openerp/sql_db.py", line 227, in execute
res = self._obj.execute(query, params)
ProgrammingError: relation "ir_model_constraint" does not exist
LINE 2: SELECT 1 FROM ir_model_constraint, ir_module_mod...
What can I do, or should I have done to upgrade?
There is no free upgrade mechanism from OpenERP 6.0 to 7.0 for now. OpenERP SA makes a living by selling a commercial upgrade solution, for which you get a considerable discount if you have a yearly support contract with them.
Using -u all will probably attempt to upgrade you database schema, but il will not migrate your data (i.e. if a column was renamed, you will not get your data moved from the old column to the new one), and the views will not be migrated either : the new views with the same XML ids replace the old ones, new views are created, and old views are still there, possibly referencing fields which no longer exist. Basically your DB is now a total mess, and hopefully you have a backup which you can use to continue running v 6.0.
Did you have installed V6.1 too in the same machine?
This error happend when you have mixed old version modules and new ones.
I recommend install a Virtual Machine and try again on it, if im right, you ca unistall the package, delete all files (modules) related to the package and re-install.
If you need to repair database to old version, re-instal 6.1 or 6.0 and bring up your server with parameters -u all -d nameofdb.
Regards.