Hi, complete noob here. Currently still learning how to ask questions so forgive me if it is either too long or doesn’t make much sense. Basically I’m creating a test case and I want to save a screenshot when there is a failure or “exception” now, currently I know of 2 ways, through filename or os. Weirdly if I use filename
self.driver.save_screenshot(filename="..\screenshots\test_account.png")
then the terminal (CMD) doesn’t recognise and doesn’t save in the screenshots directory but pycharm does. Now If I use the os path CMD saves in the “screenshots” directory but pycharm doesn’t
self.driver.save_screenshot(os.path.abspath(os.curdir) + "\screenshots\" + "test_account_reg.png")
This is what I have currently, currently I have it so it works through the terminal:
class TestAccountReg: baseURL = "https://magento.softwaretestingboard.com/" def test_account_reg(self, setup): self.driver = setup try: self.driver.get(self.baseURL) self.driver.maximize_window() self.mp=MainPage(self.driver) self.mp.clickaccount() self.rp=RegPage(self.driver) self.rp.setfirstname("Jane") self.rp.setlastname("") self.email=random_string_generator()+'@gmail.com' self.rp.setemail(self.email) self.rp.setpassword("abc123DEF") self.rp.confirmpassword("abc123DEF") self.rp.clickcreate() self.confhead=self.rp.getheadtitle() assert self.confhead=="My Account" except Exception: self.driver.save_screenshot(filename="..\screenshots\test_account.png") raise Exception
If anyone has a solution for it to work on both the terminal and pycharm that would be great thanks.
and yes, I did try copilot but it’s sending me around in loops lol
submitted by /u/Efficient_Set9050
[link] [comments]
r/learnpython Hi, complete noob here. Currently still learning how to ask questions so forgive me if it is either too long or doesn’t make much sense. Basically I’m creating a test case and I want to save a screenshot when there is a failure or “exception” now, currently I know of 2 ways, through filename or os. Weirdly if I use filename self.driver.save_screenshot(filename=”..\screenshots\test_account.png”) then the terminal (CMD) doesn’t recognise and doesn’t save in the screenshots directory but pycharm does. Now If I use the os path CMD saves in the “screenshots” directory but pycharm doesn’t self.driver.save_screenshot(os.path.abspath(os.curdir) + “\screenshots\” + “test_account_reg.png”) This is what I have currently, currently I have it so it works through the terminal: class TestAccountReg: baseURL = “https://magento.softwaretestingboard.com/” def test_account_reg(self, setup): self.driver = setup try: self.driver.get(self.baseURL) self.driver.maximize_window() self.mp=MainPage(self.driver) self.mp.clickaccount() self.rp=RegPage(self.driver) self.rp.setfirstname(“Jane”) self.rp.setlastname(“”) self.email=random_string_generator()+’@gmail.com’ self.rp.setemail(self.email) self.rp.setpassword(“abc123DEF”) self.rp.confirmpassword(“abc123DEF”) self.rp.clickcreate() self.confhead=self.rp.getheadtitle() assert self.confhead==”My Account” except Exception: self.driver.save_screenshot(filename=”..\screenshots\test_account.png”) raise Exception If anyone has a solution for it to work on both the terminal and pycharm that would be great thanks. and yes, I did try copilot but it’s sending me around in loops lol submitted by /u/Efficient_Set9050 [link] [comments]
Hi, complete noob here. Currently still learning how to ask questions so forgive me if it is either too long or doesn’t make much sense. Basically I’m creating a test case and I want to save a screenshot when there is a failure or “exception” now, currently I know of 2 ways, through filename or os. Weirdly if I use filename
self.driver.save_screenshot(filename="..\screenshots\test_account.png")
then the terminal (CMD) doesn’t recognise and doesn’t save in the screenshots directory but pycharm does. Now If I use the os path CMD saves in the “screenshots” directory but pycharm doesn’t
self.driver.save_screenshot(os.path.abspath(os.curdir) + "\screenshots\" + "test_account_reg.png")
This is what I have currently, currently I have it so it works through the terminal:
class TestAccountReg: baseURL = "https://magento.softwaretestingboard.com/" def test_account_reg(self, setup): self.driver = setup try: self.driver.get(self.baseURL) self.driver.maximize_window() self.mp=MainPage(self.driver) self.mp.clickaccount() self.rp=RegPage(self.driver) self.rp.setfirstname("Jane") self.rp.setlastname("") self.email=random_string_generator()+'@gmail.com' self.rp.setemail(self.email) self.rp.setpassword("abc123DEF") self.rp.confirmpassword("abc123DEF") self.rp.clickcreate() self.confhead=self.rp.getheadtitle() assert self.confhead=="My Account" except Exception: self.driver.save_screenshot(filename="..\screenshots\test_account.png") raise Exception
If anyone has a solution for it to work on both the terminal and pycharm that would be great thanks.
and yes, I did try copilot but it’s sending me around in loops lol
submitted by /u/Efficient_Set9050
[link] [comments]