DataDriven Framework: Part 2>Facing Timeout Exception issue everytime | Selenium Python Forum
N
Nitika Posted on 12/11/2020
 

I have used the same code as it is mentioned in the video but while login on zoho.com, after entering email id, Next button is not getting clicked and I am getting Timeout exception.I have increased the explicit wait time as well but nothing works.

When using the simple script then I am able to login using time.sleep and explicit wait as well but in framework after creating IsElementPresent and isElementVisible Function ,everytime it is throwing error.

Please help

Here is the error:

test_login.py::test_login -- listing properties --
URL=https://www.zoho.com/
loginlink_xpath=//a[text()='Login']
usernametxtbox_id=login_id
nextbutton_xpath=//*[@id='nextbtn']
passwordtxtbox_name=PASSWORD
signin_xpath=//*[@id='nextbtn']
FAILED
test_login.py:9 (test_login)
base_fixture = None

def test_login(base_fixture):
conftest.app.openbrowser("chrome")
conftest.app.maximizee()
conftest.app.navigate("URL")
conftest.app.click("loginlink_xpath")
#time.sleep(10)
conftest.app.type("usernametxtbox_id","sharmanitika1111@gmail.com")
#time.sleep(10)
> conftest.app.click("nextbutton_xpath")

test_login.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\testResources\generickeywords.py:36: in click
self.getElement(locatorKey).click()
..\testResources\generickeywords.py:116: in getElement
if(self.isElementPresent(locatorKey) and self.isElementVisible(locatorKey)):
..\testResources\generickeywords.py:93: in isElementVisible
elementList=wait.until(expected_conditions.visibility_of_all_elements_located((By.XPATH,obj)))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.support.wait.WebDriverWait (session="11e732ccf789f4aa2fd3a336907405b5")>
method = <selenium.webdriver.support.expected_conditions.visibility_of_all_elements_located object at 0x00000000044C7D88>
message = ''

def until(self, method, message=''):
"""Calls the method provided with the driver as an argument until the \
return value is not False."""
screen = None
stacktrace = None

end_time = time.time() + self._timeout
while True:
try:
value = method(self._driver)
if value:
return value
except self._ignored_exceptions as exc:
screen = getattr(exc, 'screen', None)
stacktrace = getattr(exc, 'stacktrace', None)
time.sleep(self._poll)
if time.time() > end_time:
break
> raise TimeoutException(message, screen, stacktrace)
E selenium.common.exceptions.TimeoutException: Message:

..\..\..\..\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\support\wait.py:80: TimeoutException


================================== FAILURES ===================================
_________________________________ test_login __________________________________

base_fixture = None

def test_login(base_fixture):
conftest.app.openbrowser("chrome")
conftest.app.maximizee()
conftest.app.navigate("URL")
conftest.app.click("loginlink_xpath")
#time.sleep(10)
conftest.app.type("usernametxtbox_id","sharmanitika1111@gmail.com")
#time.sleep(10)
> conftest.app.click("nextbutton_xpath")

test_login.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\testResources\generickeywords.py:36: in click
self.getElement(locatorKey).click()
..\testResources\generickeywords.py:116: in getElement
if(self.isElementPresent(locatorKey) and self.isElementVisible(locatorKey)):
..\testResources\generickeywords.py:93: in isElementVisible
elementList=wait.until(expected_conditions.visibility_of_all_elements_located((By.XPATH,obj)))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.support.wait.WebDriverWait (session="11e732ccf789f4aa2fd3a336907405b5")>
method = <selenium.webdriver.support.expected_conditions.visibility_of_all_elements_located object at 0x00000000044C7D88>
message = ''

def until(self, method, message=''):
"""Calls the method provided with the driver as an argument until the \
return value is not False."""
screen = None
stacktrace = None

end_time = time.time() + self._timeout
while True:
try:
value = method(self._driver)
if value:
return value
except self._ignored_exceptions as exc:
screen = getattr(exc, 'screen', None)
stacktrace = getattr(exc, 'stacktrace', None)
time.sleep(self._poll)
if time.time() > end_time:
break
> raise TimeoutException(message, screen, stacktrace)
E selenium.common.exceptions.TimeoutException: Message:

..\..\..\..\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\support\wait.py:80: TimeoutException
=========================== short test summary info ===========================
FAILED test_login.py::test_login - selenium.common.exceptions.TimeoutExceptio...
============================= 1 failed in 45.19s ==============================

Process finished with exit code 0

Assertion failed

Assertion failed


0
09914040666 Replied on 12/11/2020

Hey

Please carefully observe the listing properties. Thenext button and sign in button have same locators(xpath). They both share the same id, because of which selenium is unable to find the element correctly.

Try using the xpath for next button as "//span[text()='Next']" and for sign in button as "//form[@id='login']//button[@id='nextbtn']"


N
Nitika Replied on 12/11/2020

 

Now I have tried these as you mentioned because of same locators, error is throwing.

This time it works successfully.

Thanks

nextbutton_xpath=//form[@name='login']/button/span[text()='Next']
signin_xpath=//button[@id="nextbtn"]/span[text()='Sign in']


0
09914040666 Replied on 12/11/2020

Thank you for the update. 


Related Posts