Selenium searches for the xpath to be clicked in the background and gives error. Actual element to be clicked is in a box - python-2.7

Selenium searches for the xpath to be clicked in the background and gives error. Actual element to be clicked is in a box. Please see the image. I want to click on interface (22) tab. But the script throws the following error.
Traceback (most recent call last):
File "C:/Python27/Lib/site-packages/taut_mcp/communication/mcp_web.py", line 193, in <module>
mcp.interface_data_get()
File "C:\Python27\Lib\site-packages\taut_mcp\command\mcp_gui.py", line 128, in interface_data_get
self.force_click('//div[4]/div/div')
File "C:\Python27\Lib\site-packages\taut_selenium\taut_selenium.py", line 844, in force_click
found_element = self.element_find(element)
File "C:\Python27\Lib\site-packages\taut_selenium\taut_selenium.py", line 296, in element_find
found_element = self.any_condition_wait(element, real_timeout)
File "C:\Python27\Lib\site-packages\taut_selenium\taut_selenium.py", line 820, in any_condition_wait
found_element = this_wait.until(ec((by_id, this_selector)))
File "C:\Python27\Lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///c:/users/uvijayac/appdata/local/temp/tmp3wnxmc/extensions/fxdriver#googlecode.com/components/driver-component.js:10770)
at FirefoxDriver.prototype.findElement (file:///c:/users/uvijayac/appdata/local/temp/tmp3wnxmc/extensions/fxdriver#googlecode.com/components/driver-component.js:10779)
at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/uvijayac/appdata/local/temp/tmp3wnxmc/extensions/fxdriver#googlecode.com/components/command-processor.js:12661)
at DelayedCommand.prototype.executeInternal_ (file:///c:/users/uvijayac/appdata/local/temp/tmp3wnxmc/extensions/fxdriver#googlecode.com/components/command-processor.js:12666)
at DelayedCommand.prototype.execute/< (file:///c:/users/uvijayac/appdata/local/temp/tmp3wnxmc/extensions/fxdriver#googlecode.com/components/command-processor.js:12608)

Related

Selenium doesn't open the browser in Python

I'm new in Python and I'm trying to use Selenium in Debian but it doesn't work, more concretely it seems to stay in a loop and nothing happens. The next script is the test that I've used:
#!/usr/bin/env python
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.python.org')
When I interrupt the script the following text appears:
Traceback (most recent call last):
File "prueba_parseo.py", line 7, in browser =
webdriver.Firefox() File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py",
line 154, in init
keep_alive=True)
File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 140, in init
self.start_session(desired_capabilities, browser_profile)
File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 295, in execute
response = self.command_executor.execute(driver_command, params)
File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
line 464, in execute
return self._request(command_info[0], url, body=data)
File
"/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py",
line 488, in _request
resp = self._conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1111, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 444, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 400, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
I've been searching for an answer, but nothing works. I've changed the versions of the packages, export no_proxy="localhost,127.0.0.1"
OS: Debian 5
Python: 2.7
Selenium: 3.5
Geckodriver: 0.17.0
Firefox: 52.0
I don't know what else to do or what to change.
Thank you very much!
My guess is that it actually all goes well and the browser is started in background. The reason why it's staying open is probably because of the default option keep_alive=True I can see in your traceback.
Try closing the browser using browser.close() or browser.quit() when you are done with the tests.
From the documentation:
Finally, the browser window is closed. You can also call quit method
instead of close. The quit will exit entire browser whereas close`
will close one tab, but if just one tab was open, by default most
browser will exit entirely.
http://selenium-python.readthedocs.io/getting-started.html#simple-usage

Error while using cql connect

con = cql.connect(host="127.0.0.1",port=9160,keyspace="my_keyspace",cql_version='3.0.0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/cql/connection.py", line 143, in connect
File "build/bdist.linux-x86_64/egg/cql/connection.py", line 63, in __init__
File "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 177, in set_initial_keyspace
File "build/bdist.linux-x86_64/egg/cql/cursor.py", line 80, in execute
File "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 77, in get_response
File "build/bdist.linux-x86_64/egg/cql/thrifteries.py", line 98, in handle_cql_execution_errors
cql.apivalues.ProgrammingError: Bad Request: You have not logged in
I am very new to cassandra,please let me know what wrong am i doing here.
Assuming you are using https://pypi.python.org/pypi/cql, if you go to the home page, it says this is deprecated https://code.google.com/archive/a/apache-extras.org/p/cassandra-dbapi2
I would recommend using cassandra-driver
https://datastax.github.io/python-driver
Go to \var\log\cassandra there you must find system.log file. There you should see an error

How to get testplanid in testlink project

How to get testplanid in testlink project? I have given name 'myTestProjectTestBuild' to my test plan, but while giving this name as testplanid, it says The Test Plan ID (0) provided does not exist!
>>> tls.getBuildsForTestPlan('myTestProjectTestBuild')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/testlink/testlinkdecorators.py", line 140, in wrapperReplaceTLResponseError
response = methodAPI(self, *argsPositional, **argsOptional)
File "/usr/lib/python2.7/site-packages/testlink/testlinkdecorators.py", line 112, in wrapperAddDevKey
return methodAPI(self, *argsPositional, **argsOptional)
File "/usr/lib/python2.7/site-packages/testlink/testlinkdecorators.py", line 100, in wrapperWithArgs
*argsPositional, **argsOptional)
File "/usr/lib/python2.7/site-packages/testlink/testlinkapigeneric.py", line 1515, in callServerWithPosArgs
self._checkResponse(response, methodNameAPI, argsOptional)
File "/usr/lib/python2.7/site-packages/testlink/testlinkapigeneric.py", line 1879, in _checkResponse
response[0]['message'], response[0]['code'])
testlink.testlinkerrors.TLResponseError: 3000: (getBuildsForTestPlan) - The Test Plan ID (0) provided does not exist!
getBuildsForTestPlan({'testplanid': 'myTestProjectTestBuild', 'devKey': 'xyz'})
Can someone let me know from where I can get testplanid in testlink?
I got the value of testplanid with tls.getProjectTestPlans('<project_id').
After login, you will get a test plan management link, click it then hover over the test plan that you want to get its Id. At the bottom you will see tplan_id = some number. That is the test plan ID

How to resolve "_tkinter.TclError: unknown option"?

I am learning python tkinter but I have an error whenever I tried to compile it:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/
widgets/externalshell/sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "/home/jason/.spyder2/.temp.py", line 14, in <module>
menu.config(menu=menu)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1274,
inconfigure
return self._configure('configure', cnf, kw)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1265,
in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-menu").
My code is:
from tkinter import *
def hello():
print "hello"
root = Tk()
menu = Menu(root)
menu.config(menu=menu)
menu.add_command(label ="new",command = hello)
root.mainloop()
You have an issue with your code a little bit. Instead of menu.config, use root.config, you will not get any such errors.
For more information and detailed tutorial, kindly visit Tkinter Menu Widget.

Scrapy cannot handle bad headers properly [ScrapyHTTPPageGetter,client] Unhandled Error

Environment:
Scrapy 0.16.2
Twisted-12.2.0
python 2.7
macosx-10.6
Okey here is my problem:
I try to run
scrapy shell http://aaa.17domn.com/bt9/file.php/MERH77V.html
Error:
[ScrapyHTTPPageGetter,client] Unhandled Error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/internet/selectreactor.py", line 150, in _doReadOrWrite
why = getattr(selectable, method)()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/internet/tcp.py", line 202, in doRead
return self._dataReceived(data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/internet/tcp.py", line 208, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/protocols/basic.py", line 564, in dataReceived
why = self.lineReceived(line)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Scrapy-0.16.2-py2.7.egg/scrapy/core/downloader/webclient.py", line 50, in lineReceived
return HTTPClient.lineReceived(self, line.rstrip())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/web/http.py", line 450, in lineReceived
self.extractHeader(self._header)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/web/http.py", line 406, in extractHeader
key, val = header.split(':',1)
exceptions.ValueError: need more than 1 value to unpack
I found the solution from https://groups.google.com/forum/#!msg/scrapy-users/xFKo8ggzPxs/VXDl3CZ4V4cJ
They describe this is caused by twisted. Then I patched function extractHeader in /twisted/web/http.py from http://twistedmatrix.com/trac/ticket/2842. Its WORKS
BUT BUT, Hold on NOt yet!!!
I run another web
scrapy shell http://www1.wkdown.info/fs3/file.php/M994ATR.html
Error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-macosx-10.6-intel.egg/twisted/internet/defer.py", line 551, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Scrapy-0.16.2-py2.7.egg/scrapy/core/downloader/webclient.py", line 122, in _build_response
status = int(self.status)
ValueError: invalid literal for int() with base 10: 'html'
I think something happen on response headers. Scrapy cannot handle it well.
Any idea?
Thank you!