screenshot isn’t working /u/Efficient_Set9050 Python Education

Hi guys, I’m currently trying to save a screenshot everytime my test case fails but even if the test run gets to the end and the error is “AssertionError” and the png isn’t saved to my designated folder. This is currently what I have:

Note: the code can be found at the bottom under “else” it’s setup correctly indent format wise, I’m not sure why it’s left indented here (maybe too long)

from pageObjects.HomePage import HomePage from pageObjects.AccountsRegistrationPage import AccountRegistrationPage from utilities import randomeString from utilities.readProperties import readconfig import os import time class Test_001_AccountReg: baseURL = "https://demo.opencart.com/" def test_account_reg(self,setup): self.driver=setup self.driver.get(self.baseURL) self.driver.maximize_window() time.sleep(8) self.hp=HomePage(self.driver) self.hp.clickMyAccount() time.sleep(8) self.hp.clickMyAccount() time.sleep(8) self.hp.clickRegister() self.regpage=AccountRegistrationPage(self.driver) self.regpage.setFirstName("John") time.sleep(2) self.regpage.setLastName("Candy") self.email=randomeString.random_string_generator()+'@gmail.com' time.sleep(2) self.regpage.setEmail(self.email) time.sleep(2) self.regpage.setPassword("adF1") time.sleep(2) self.regpage.setPrivacyPolicy() time.sleep(2) self.regpage.clickContinue() time.sleep(2) self.confmsg=self.regpage.getconfirmationmsg() if self.confmsg=="Your Account Has Been Created": assert True self.driver.close() else: self.driver.save_screenshot(os.path.abspath(os.curdir)+"\screenshots\"+"test_account_reg.png") self.driver.close() assert False 

I’m currently working off a course that seems to be outdated so please let me know if there is anything wrong. Thanks again

submitted by /u/Efficient_Set9050
[link] [comments]

​r/learnpython Hi guys, I’m currently trying to save a screenshot everytime my test case fails but even if the test run gets to the end and the error is “AssertionError” and the png isn’t saved to my designated folder. This is currently what I have: Note: the code can be found at the bottom under “else” it’s setup correctly indent format wise, I’m not sure why it’s left indented here (maybe too long) from pageObjects.HomePage import HomePage from pageObjects.AccountsRegistrationPage import AccountRegistrationPage from utilities import randomeString from utilities.readProperties import readconfig import os import time class Test_001_AccountReg: baseURL = “https://demo.opencart.com/” def test_account_reg(self,setup): self.driver=setup self.driver.get(self.baseURL) self.driver.maximize_window() time.sleep(8) self.hp=HomePage(self.driver) self.hp.clickMyAccount() time.sleep(8) self.hp.clickMyAccount() time.sleep(8) self.hp.clickRegister() self.regpage=AccountRegistrationPage(self.driver) self.regpage.setFirstName(“John”) time.sleep(2) self.regpage.setLastName(“Candy”) self.email=randomeString.random_string_generator()+’@gmail.com’ time.sleep(2) self.regpage.setEmail(self.email) time.sleep(2) self.regpage.setPassword(“adF1″) time.sleep(2) self.regpage.setPrivacyPolicy() time.sleep(2) self.regpage.clickContinue() time.sleep(2) self.confmsg=self.regpage.getconfirmationmsg() if self.confmsg==”Your Account Has Been Created”: assert True self.driver.close() else: self.driver.save_screenshot(os.path.abspath(os.curdir)+”\screenshots\”+”test_account_reg.png”) self.driver.close() assert False I’m currently working off a course that seems to be outdated so please let me know if there is anything wrong. Thanks again submitted by /u/Efficient_Set9050 [link] [comments] 

Hi guys, I’m currently trying to save a screenshot everytime my test case fails but even if the test run gets to the end and the error is “AssertionError” and the png isn’t saved to my designated folder. This is currently what I have:

Note: the code can be found at the bottom under “else” it’s setup correctly indent format wise, I’m not sure why it’s left indented here (maybe too long)

from pageObjects.HomePage import HomePage from pageObjects.AccountsRegistrationPage import AccountRegistrationPage from utilities import randomeString from utilities.readProperties import readconfig import os import time class Test_001_AccountReg: baseURL = "https://demo.opencart.com/" def test_account_reg(self,setup): self.driver=setup self.driver.get(self.baseURL) self.driver.maximize_window() time.sleep(8) self.hp=HomePage(self.driver) self.hp.clickMyAccount() time.sleep(8) self.hp.clickMyAccount() time.sleep(8) self.hp.clickRegister() self.regpage=AccountRegistrationPage(self.driver) self.regpage.setFirstName("John") time.sleep(2) self.regpage.setLastName("Candy") self.email=randomeString.random_string_generator()+'@gmail.com' time.sleep(2) self.regpage.setEmail(self.email) time.sleep(2) self.regpage.setPassword("adF1") time.sleep(2) self.regpage.setPrivacyPolicy() time.sleep(2) self.regpage.clickContinue() time.sleep(2) self.confmsg=self.regpage.getconfirmationmsg() if self.confmsg=="Your Account Has Been Created": assert True self.driver.close() else: self.driver.save_screenshot(os.path.abspath(os.curdir)+"\screenshots\"+"test_account_reg.png") self.driver.close() assert False 

I’m currently working off a course that seems to be outdated so please let me know if there is anything wrong. Thanks again

submitted by /u/Efficient_Set9050
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *