You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
get the list of elements which are displayed after the search
currently on result page using find_elements_by_class_name method
lists = driver.find_elements_by_class_name("_Rm")
get the number of elements found
print str(len(lists))
iterate through each element and print the text that is
name of the search
i = 0
for listitem in lists:
print (listitem)
i = i + 1
if (i > 10):
break
close the browser window
driver.quit()
After running the code using
Python Assign1.py
it is showing following error while opening fire fox browser
After clicking on close program it showing following errors on command prompt:
Traceback (most recent call last):
File "Assign1.py", line 5, in
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 85, in init
keep_alive=True)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 90, in init
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 234, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 401, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 432, in _request
resp = self._conn.getresponse()
File "C:\Python27\lib\httplib.py", line 1136, in getresponse
response.begin()
File "C:\Python27\lib\httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "C:\Python27\lib\httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "C:\Python27\lib\socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054] An existing connection was forcibly closed by the re
mote host
The text was updated successfully, but these errors were encountered:
below is my code for Assign1.py file
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
create a new Firefox session
driver = webdriver.Firefox()
driver.implicitly_wait(30)
driver.maximize_window()
navigate to the application home page
driver.get("http://www.google.com")
get the search textbox
search_field = driver.find_element_by_id("lst-ib")
search_field.clear()
enter search keyword and submit
search_field.send_keys("Selenium WebDriver Interview questions")
search_field.submit()
get the list of elements which are displayed after the search
currently on result page using find_elements_by_class_name method
lists = driver.find_elements_by_class_name("_Rm")
get the number of elements found
print str(len(lists))
iterate through each element and print the text that is
name of the search
i = 0
for listitem in lists:
print (listitem)
i = i + 1
if (i > 10):
break
close the browser window
driver.quit()
After running the code using
Python Assign1.py
it is showing following error while opening fire fox browser
After clicking on close program it showing following errors on command prompt:
Traceback (most recent call last):
File "Assign1.py", line 5, in
driver = webdriver.Firefox()
File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py",
line 85, in init
keep_alive=True)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 90, in init
self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", l
ine 234, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 401, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connectio
n.py", line 432, in _request
resp = self._conn.getresponse()
File "C:\Python27\lib\httplib.py", line 1136, in getresponse
response.begin()
File "C:\Python27\lib\httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "C:\Python27\lib\httplib.py", line 409, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "C:\Python27\lib\socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054] An existing connection was forcibly closed by the re
mote host
The text was updated successfully, but these errors were encountered: