Hi I am new in Selenium Webdriver and I am currently creating a test case for a specific function.
I have a current test case that is already working for another function, but when I include a new test case and run it. I receive an error: BadStatusLine.
Also when I run the individual test case it work perfectly fine, but when I run the whole test I will receive an error: BadStatusLine.
ERROR: test_task_xml (__main__.TestActuserLayouts)
Test if the task xml is hidden
----------------------------------------------------------------------
Traceback (most recent call last):
File "acttemplate_layouts.py", line 25, in setUp
driver.find_element_by_name("password").submit()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 84, in submit
self._execute(Command.SUBMIT_ELEMENT)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 457, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 231, 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 395, 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 426, in _request
resp = self._conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 415, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 379, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''
This is the whole test:
import unittest
from selenium import webdriver
class TestActuserLayouts(unittest.TestCase):
"""Test user functions """
driver = webdriver.Firefox()
driver.implicitly_wait(30)
base_url = "http://samplepage.com"
def setUp(self):
"""Base setting before test
"""
driver = self.driver
# Login
driver.get(self.base_url + "/")
driver.find_element_by_name("user_name").clear()
driver.find_element_by_name("user_name").send_keys("userme")
driver.find_element_by_name("password").clear()
driver.find_element_by_name("password").send_keys("123")
driver.find_element_by_name("password").submit()
self.assertEqual(self.base_url + "/userme/inbox/", driver.current_url)
def test_task_xml(self):
"""Test if the task xml is hidden
"""
driver = self.driver
# Get page by URL
driver.get(self.base_url + "/userme/mission/")
# Get page by URL
driver.get(self.base_url + "/mission/update/0000000a-0000-0000-0000-000000000000/")
self.assertEqual(self.base_url + "/mission/update/0000000a-0000-0000-0000-000000000000/", driver.current_url)
driver.find_element_by_id("discussion-btn").click()
# Scan browser if Task xml is not present
self.assertFalse('Task xml' in self.driver.page_source)
def test_task_list(self):
"""Test if the number of task for each mission is null
"""
driver = self.driver
#Get page url
driver.get(self.base_url + "/userme/mission/")
#Get page url
driver.get(self.base_url + "/acttemplate/list-all/")
#Scan browser if the number of task is null
self.assertEqual(driver.find_element_by_xpath("//tr[3]/td[4]").text != "", True)
def tearDown(self):
"""Clear setting after test
"""
self.driver.close()
# Run unit test directly
if __name__ == "__main__":
unittest.main()
While the other test case is a failure. So, I am not really familiar with selenium and I need help to locate this error. Can someone please help me in this issue. Thanks a lot.
I'm not sure, but I'll make a guess. Somehow, browser dies while you perform such actions like pressing buttons, clicking.
It's an error raised by httplib (low-level python http library), means that server inside browser didn't responded any of known http status codes (200, 300, 500, etc.), and instead, the response was '' (empty string).
Related
I'm trying to scrape the HTML code of a new chrome tab, but I can't find a way that works using Python.
Here's what I've tried:
I've tried the requests module, but this code:
import requests
URL = "chrome://newtab"
page = requests.get(URL)
print(page.text)
Yields this error:
Traceback (most recent call last):
File "c:\Users\Ben Bistline\Code\PythonFiles\PythonFiles\chromescrape.py", line 4, in <module>
page = requests.get(URL)
File "C:\Users\Ben Bistline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\Ben Bistline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Ben Bistline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Ben Bistline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 649, in send
adapter = self.get_adapter(url=request.url)
File "C:\Users\Ben Bistline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\sessions.py", line 742, in get_adapter
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for 'chrome://newtab'
I suppose this result makes sense, but I'm not sure how/if I can get around it.
I've also tried using the webbrowser module with this code:
import requests, webbrowser
URL = "chrome://newtab"
chromePath = 'C:/Program Files/Google/Chrome/Application/chrome.exe %s'
webbrowser.get(chromePath).open(URL)
Unfortunately, although successful, this method does not seem to offer a way of gathering the HTML.
Anyone know of any other ways using Python to grab the HTML of a new Chrome tab?
Thanks!
You can use Selenium driver with Chrome to do that
from selenium import webdriver
browser = webdriver.Chrome()
browser.get('chrome://newtab')
content = driver.page_source
browser.close()
I'm trying to learn web scraping in python with the request-html package. At first, I render a mainpage and pull out all the necessary links. That works just fine. Later I iterate over all links and render the specific subpage for that link. 2 Iterations are successful, but with the third I get an error that i am unable to solve.
Here is my code:
# import HTMLSession from requests_html
from requests_html import HTMLSession
# create an HTML Session object
session = HTMLSession()
# Use the object above to connect to needed webpage
baseurl = 'http://www.möbelfreude.de/'
resp = session.get(baseurl+'alle-boxspringbetten')
# Run JavaScript code on webpage
resp.html.render()
links = resp.html.find('a.image-wrapper.text-center')
for link in links:
print('Rendering... {}'.format(link.attrs['href']))
r = session.get(baseurl + link.attrs['href'])
r.html.render()
print('Completed rendering... {}'.format(link.attrs['href']))
# do stuff
Error:
Completed rendering... bett/boxspringbett-bea
Rendering... bett/boxspringbett-valina
Completed rendering... bett/boxspringbett-valina
Rendering... bett/boxspringbett-benno-anthrazit
Traceback (most recent call last):
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
chunked=chunked)
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\site-packages\urllib3\connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 1336, in getresponse
response.begin()
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 306, in begin
version, status, reason = self._read_status()
File "C:\Users\pasca\AppData\Local\Programs\Python\Python37-32\lib\http\client.py", line 275, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:```
The error is due to the connection closure, and may be due to some configurations on the server side.
Have you scraping the site and appending the links to a list.
Then request each link individually to find and locate the specific directory that is cause issue.
Using dev mode in chrome under the network tab can help identify the necessary headers for requests that require them.
We have a Selenium process that fetches data from our data provider for further processing. The process tries to get all historical data, and since we do not have functionality to reliably filter out data that has been edited recently, we must get full data dumps from time to time to ensure that no records are dropped.
The Selenium process is written as a Python script. It goes to a specific website, logs in, presses a button that triggers report generation, and then downloads the report. The issue is that for full dump reports, the report generation has started to take longer than the default Selenium timeouts.
We use the Google Chrome driver, but would be willing to change the browser/driver if only other drivers have the ability to fully disable timeouts.
Below is a simplified, stripped-down version of the code with just the bare bones needed to appropriately describe this issue. The places where the report times out are marked out. It's waiting for a response from the website after clicking a button. How to disable that, and why what we currently do (can be seen below) is not enough?
from selenium import webdriver
def selectPopUp(driver, main_window_handle, maxWait=100):
"""
Selects a pop-up window. If no pop-up window appears, raises an
Exception.
:param maxWait: how long to wait (in seconds) before raising the error?
"""
popup_window_handle = None
i = 0
while (not popup_window_handle) and (i < maxWait):
for handle in driver.window_handles:
if handle != main_window_handle:
popup_window_handle = handle
break
# Wait a litle and re-iterate.
time.sleep(1)
i += 1
if popup_window_handle != None:
driver.switch_to.window(popup_window_handle)
return popup_window_handle
else:
raise Exception("No pop-up window appeared although the program was expecting one.")
def selectOption(dropdown, option, possibilities):
"""
Validates and selects an option from a drop-down.
:param dropdown: the Selenium reference to the dropdown selection.
:param option: the name of the option we'll select
:param possibilities: the possibilities we allow to choose from --
will raise an Exception
if `option` is not in `possibilities`.
:returns: Selenium selection.
"""
# Select the default Excel option
if option in possibilities:
return dropdown.find_element_by_xpath("//option[#value='" + option + "']")\
.click()
else:
raise Exception("Invalid choice! Use one of the following: \n\n " + \
"\n ".join(possibilities))
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : DOWNLOAD_DIRECTORY}
chromeOptions.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(executable_path=settings.chromeDriver,
chrome_options=chromeOptions)
# Set an infite timeout time so that the slow Crystal reports
# would stand a chance of not timing out too.
driver.set_page_load_timeout(9999999999)
driver.set_script_timeout(9999999999)
# We go to the relevant website - that part is edited out.
# Once in the website, we select the current window handle
# to be able to come back to it after navigating through pop-ups.
main_window_handle = driver.current_window_handle
reportDropDown = driver.find_element_by_id(REPORT_ELEMENT_ID)
selectedReport = reportDropDown.find_element_by_xpath("//option[#value='" + SELCTED_REPORT_TITLE + "']")
selectedReport.click()
########################################################################
# >>>>>>>> The first place where the process keeps timing out. <<<<<<< #
########################################################################
# Click on the export button to open export pop-up.
exportButton = driver.find_element_by_name(r'crytlViewer$ctl02$ctl00')
exportButton.click()
# Now a pop-up with a download button appears. Select it.
popUpHandle = selectPopUp(driver, main_window_handle)
# Now, select a particular download format.
formatDropDown = driver.find_element_by_id("exportFormatList")
selectedFormat = selectOption(formatDropDown, reportFormat, REPORT_FORMAT_LIST)
# Download the report.
driver.find_element_by_id("submitexport").click()
#########################################################################
# >>>>>>>> The second place where the process keeps timing out. <<<<<<< #
#########################################################################
An representative example of an error message we get would be the following.
Traceback (most recent call last):
File "/home/ubuntu/main/oodle/core/utils.py", line 296, in repeatUntilSuccess
return func()
File "/home/ubuntu/main/oodle/salesforce/data_feed.py", line 277, in <lambda>
cleanUp=True),
File "/home/ubuntu/main/oodle/salesforce/data_feed.py", line 322, in pushReports
'liveEnvironment': self.liveEnvironment}]\
File "/home/ubuntu/main/oodle/core/reporting.py", line 1160, in __getitem__
self.handlers[name].PreparePandas(**paramDict)
File "/home/ubuntu/main/oodle/reports/vienna_salesforce_data_feed/Salesforce_LoanObject_Parsed.py", line 38, in PreparePandas
loan = self.manager.handlers[crystalReport].PreparePandas()
File "/home/ubuntu/main/oodle/core/reporting.py", line 1231, in PreparePandas
return self.TransformRaw(self.GetRaw(fileFrom))
File "/home/ubuntu/main/oodle/core/reporting.py", line 1387, in GetRaw
self.PrepareExcel(fileFrom)
File "/home/ubuntu/main/oodle/core/reporting.py", line 1367, in PrepareExcel
fileTo=fileTo)
File "/home/ubuntu/main/oodle/vienna/crystal.py", line 293, in downloadReport
self.downloadReport_no_error_handling(reportTitle, reportFormat, fileTo)
File "/home/ubuntu/main/oodle/vienna/crystal.py", line 247, in downloadReport_no_error_handling
self.driver.find_element_by_id("submitexport").click()
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 77, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 493, in _execute
return self._parent.execute(command, params)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
TimeoutException: Message: timeout
(Session info: chrome=60.0.3112.78)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-1052-aws x86_64)
After edits suggested by Alexey Dolgopolov, we get the following error message, which is slightly different from the previous one:
Traceback (most recent call last):
File "/home/ubuntu/main/oodle/core/utils.py", line 296, in repeatUntilSuccess
return func()
File "/home/ubuntu/main/oodle/salesforce/data_feed.py", line 277, in <lambda>
cleanUp=True),
File "/home/ubuntu/main/oodle/salesforce/data_feed.py", line 322, in pushReports
'liveEnvironment': self.liveEnvironment}]\
File "/home/ubuntu/main/oodle/core/reporting.py", line 1160, in __getitem__
self.handlers[name].PreparePandas(**paramDict)
File "/home/ubuntu/main/oodle/reports/vienna_salesforce_data_feed/Salesforce_LoanObject_Parsed.py", line 38, in PreparePandas
loan = self.manager.handlers[crystalReport].PreparePandas()
File "/home/ubuntu/main/oodle/core/reporting.py", line 1231, in PreparePandas
return self.TransformRaw(self.GetRaw(fileFrom))
File "/home/ubuntu/main/oodle/core/reporting.py", line 1387, in GetRaw
self.PrepareExcel(fileFrom)
File "/home/ubuntu/main/oodle/core/reporting.py", line 1367, in PrepareExcel
fileTo=fileTo)
File "/home/ubuntu/main/oodle/vienna/crystal.py", line 318, in downloadReport
try:
File "/home/ubuntu/main/oodle/vienna/crystal.py", line 254, in downloadReport_no_error_handling
exportButton.click()
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 77, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/home/ubuntu/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
TimeoutException: Message: timeout
(Session info: chrome=60.0.3112.78)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.10.0-26-generic x86_64)
When you find_element_by_<whatever> an implicitly_wait timeout plays. The default value is 0.
I guess, you don't need to disable timeouts. Try using Explicit Wait. Read about it http://selenium-python.readthedocs.io/waits.html and https://seleniumhq.github.io/selenium/docs/api/py/webdriver_support/selenium.webdriver.support.wait.html#module-selenium.webdriver.support.wait.
And use something like this:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
...
selectedReport.click()
exportButton = WebDriverWait(driver, 9999, 5).until(
EC.visibility_of_element_located(
(By.NAME, r'crytlViewer$ctl02$ctl00')
)
I am having a complex python-selenium test suite to test a non-public webpage. In that setup I need to get the webdriver like follows:
self.driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)
with some profile and log path. In most cases this line of code just works fine, but sometimes (5% or the cases) I get a socket timeout error:
File "/root/tests/usecase_tests/tools/basicsuite.py", line 213, in set_driver_firefox
self.driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 158, in __init__
keep_alive=True)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 309, 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 460, 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 484, in _request
resp = self._conn.getresponse()
File "/usr/lib/python2.7/httplib.py", line 1136, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out
What could be a possible cause of this error? How to debug this error? How to fix it?
The error says it all :
File "/usr/lib/python2.7/socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out
Sequence of events
Here is the sequence of events that happened :
Initially the error occurs at the following line in basicsuite.py file :
self.driver = webdriver.Firefox(firefox_profile = profile, log_path = logfile)
After a series of checks finally the following method is called which fails :
def readinto(self, b):
"""Read up to len(b) bytes into the writable buffer *b* and return
the number of bytes read. If the socket is non-blocking and no bytes
are available, None is returned.
If *b* is non-empty, a 0 return value indicates that the connection
was shutdown at the other end.
"""
self._checkClosed()
self._checkReadable()
if self._timeout_occurred:
raise OSError("cannot read from timed out object")
while True:
try:
return self._sock.recv_into(b)
except timeout:
self._timeout_occurred = True
raise
except error as e:
if e.args[0] in _blocking_errnos:
return None
raise
The program errors out at :
self._sock.recv(b) # where If *b* is non-empty, a 0 return value indicates that the connection was shutdown at the other end.
Conclusion
The conclusion is that the attempt to make the Connection wasn't successfull which means the initialization of the webdriver instance and further spawning of a new Mozilla Firefox Browser Session was unsuccessful.
Analysis
It won't be possible to conclude the real reason why timeout: timed out occured. But you can follow some of the Best Practices as follows :
Provide the complete name of the logfile along with the logical location of the logfile (from Project Level) as follows :
self.driver = webdriver.Firefox(firefox_profile=profile, log_path='./Log/geckodriver.log')
Always use quit() in the tearDown() method so that the webdriver and the webclient both are properly destroyed.
Before starting your Test Execution, through Task Manager ensure that there are no dangling instances of GeckoDriver or Firefox process within your system.
Ensure that the binary versions you are using JDK, Selenium, GeckoDriver, Mozilla Firefox Browser are compatible. You can find a detailed discussion in this QA Selenium WebDriver 3.4.0 + geckodriver 0.18.0 + Firefox ?? - which combination works?
Clean the Project Workspace from your IDE before and after executing your Test Suite.
Use CCleaner tool regularly to wipe off the OS chores.
If the base version of Firefox Browser is too ancient, uninstall the Firefox Browser through Revo Uninstaller with Moderate Scan and install a recent GA-Released version of Firefox Browser.
This happened to me in my Django app. The problem went away when I set DEBUG = False in my settings.py file.
it's probably not related but
if you are using vs-code on windows and you got this error just try to run from cmd, not from vs-code
I'm getting an error the first time I try to get an element. Notice that second time I try that it actually works. This is a debug session:
>>> self.selenium.find_element_by_xpath('//*[#id="add-button"]')
Traceback (most recent call last):
File "/home/vagrant/.pycharm_helpers/pydev/pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<input>", line 1, in <module>
File "/vagrant/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 232, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "/vagrant/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 664, in find_element
{'using': by, 'value': value})['value']
File "/vagrant/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 173, in execute
response = self.command_executor.execute(driver_command, params)
File "/vagrant/venv/lib/python3.4/site-packages/selenium/webdriver/remote/remote_connection.py", line 349, in execute
return self._request(command_info[0], url, body=data)
File "/vagrant/venv/lib/python3.4/site-packages/selenium/webdriver/remote/remote_connection.py", line 380, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.4/http/client.py", line 1147, in getresponse
response.begin()
File "/usr/lib/python3.4/http/client.py", line 351, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.4/http/client.py", line 321, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: ''
>>> self.selenium.find_element_by_xpath('//*[#id="add-button"]')
<selenium.webdriver.remote.webelement.WebElement object at 0x7f90ab074400>
And this is the code:
from selenium.webdriver.firefox.webdriver import WebDriver
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from xvfbwrapper import Xvfb
class UIPropertyTestCase(StaticLiveServerTestCase):
fixtures = ['properties']
#classmethod
def setUpClass(cls):
cls.vdisplay = Xvfb()
cls.vdisplay.start()
cls.selenium = WebDriver()
cls.selenium.implicitly_wait(10)
super(UIPropertyTestCase, cls).setUpClass()
#classmethod
def tearDownClass(cls):
cls.selenium.quit()
cls.vdisplay.stop()
super(UIPropertyTestCase, cls).tearDownClass()
def test_add_property(self):
self.selenium.get('{0}{1}'.format(self.live_server_url, '/#/app/properties'))
self.selenium.find_element_by_xpath('//*[#id="add-button"]').click()
self.selenium.get('{0}{1}'.format(self.live_server_url, '/#/app/properties'))
count = len(self.selenium.find_elements_by_xpath('//*[#id="data"]/tbody/tr'))
self.assertEqual(count, 3)
Found this comment on /usr/lib/python3.4/http/client.py:319:
Presumably, the server closed the connection before sending a valid
response.
Additional info:
OS: Ubuntu 14.04.2 LTS
Python: 3.4.0
Django: 1.7.6
selenium: 2.45.0
Firefox: 36.0.4
Any idea what could I be missing?
As said when something goes strange with Selenium it is usually good idea to update it and also update firefox.
In your case are you sure that element was actually loaded? I can see implicitly wait method but loading time may vary so it might be not enough.
You can start by increasing implicitly_wait time and try once again.