<reponame>zahed3795/Super-Automation
from automation import BaseCase


class Torqata_Test_Class(BaseCase):

    # UNIT TEST 00001----Test id 00001
    def test_torqata_00001(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '1234567890')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '!@#$%^&*()_+-')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        print("\nUNIT TEST 00001----Test id 00001 passed")

    # INTEGRATION TEST 00002----Test id 00002
    def test_torqata_00002(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '1234567890')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '!@#$%^&*()_+-')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        # User Press on PASSWORD box and enter any password
        self.click("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '!@#$%^&*()_+-')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", 'invalid')
        print("\nINTEGRATION TEST 00002----Test id 00002 passed")

    # End To End Test ---Test Id 00003
    def test_torqata_00003(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        # User Press on PASSWORD box and enter invalid password
        self.click("//input[@name='password']")
        self.input("//input[@name='password']", '<EMAIL>')
        # User Click the  Sign In button
        self.is_text_visible("Sign In", "//span[contains(text(),'Sign In')]")
        self.click("//span[contains(text(),'Sign In')]")
        invalid_credentials = self.get_text("//div[contains(text(),'Login Error: Invalid credentials.')]")
        assert "Login Error: Invalid credentials.", invalid_credentials
        print(invalid_credentials)
        print("\nEnd To End Test ---Test Id 00003 passed")

    # End To End Test ---Test Id 00004
    def test_torqata_00004(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        # User Click the  ‘Solutions’ dropdown
        self.click('//header//div[2]/ul[1]/li[1]/a[1]')
        # User Click on  ‘Profit Experts’ option
        self.click("//a[contains(text(),'Profit Expert')]")
        # Should be able to click YouTube play button
        # User check video plays 1:36 min
        profit_expert = self.get_text("//h3[contains(text(),'Profit Expert')]")
        assert "Profit Expert", profit_expert
        profit_expert_youtube_url = self.get_attribute("//*[@id='product-section-id']"
                                                       "/div/div[2]/div[2]/div[2]/iframe", 'src')
        status_code = self.get_link_status_code(profit_expert_youtube_url)
        if status_code == 200:
            print('\nProfit Expert video is ok')
        self.open('https://www.youtube.com/watch?v=gnX_aKL8DDg')
        self.click("//*[@id='movie_player']/div[24]/div[2]/div[1]/button")
        self.click("//*[@id='movie_player']/div[24]/div[2]/div[1]/button")
        # User click on  setting icon
        self.click("//div[@id='movie_player']/div[24]/div[2]/div[2]/button[3]")
        # User click on Quality
        self.click("//div[@id='ytp-id-17']/div/div/div[3]/div[3]/div")
        # User select on 720p
        self.click("//div[@id='ytp-id-17']/div/div[2]/div[2]/div/div")
        self.sleep(4)
        print("\nEnd To End Test ---Test Id 00004 passed")

    # END TO END TEST 00005----Test id 00005
    def test_torqata_00005(self):
        # Users Go to https://torqata.com/
        self.open("https://torqata.com/")
        # Users Click the  ‘Resources’ dropdown
        self.click("//a[contains(text(),'Resources')]")
        # Users Click on  ‘Blog’ option
        self.click("//div/a[1][contains(text(),'Blog')]")
        # Users scroll link into view and click link on  Podcast: Building Flask APIs for data scientists
        self.scroll_to("//a[contains(text(),'Podcast: Building Flask APIs for data scientists')]")
        self.click("//a[contains(text(),'Podcast: Building Flask APIs for data scientists')]")
        # Users verify text ‘By Author: <NAME>’ visible
        self.assert_element_present("//span[contains(text(),'<NAME>')]")
        # Users verifies text “Featuring: <NAME>” is present
        self.assert_element_present("//a[contains(text(),'<NAME>')]")
        # Users click on link podcast link
        self.click("//a[contains(text(),'https://talkpython.fm/episodes/show/226/building-flask-apis-for-data"
                   "-scientists')]")
        self.switch_to_window(1)
        # Users Verify the name <NAME> in podcast site
        self.assert_element_present("//div[1][contains(text(),'<NAME>')]")
        guest = self.get_text("//div[1][contains(text(),'<NAME>')]")
        assert guest == '<NAME>'
        print("\nEND TO END TEST 00005----Test id 00005 passed")

from automation import BaseCase


class Torqata_Test_Class(BaseCase):

    # UNIT TEST 00001----Test id 00001
    def test_torqata_00001(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '1234567890')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '!@#$%^&*()_+-')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        print("\nUNIT TEST 00001----Test id 00001 passed")

    # INTEGRATION TEST 00002----Test id 00002
    def test_torqata_00002(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<PASSWORD>')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '1234567890')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '!@#$%^&*()_+-')
        self.clear("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        # User Press on PASSWORD box and enter any password
        self.click("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '<PASSWORD>')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", '!@#$%^&*()_+-')
        self.clear("//input[@name='password']")
        self.input("//input[@name='password']", 'invalid')
        print("\nINTEGRATION TEST 00002----Test id 00002 passed")

    # End To End Test ---Test Id 00003
    def test_torqata_00003(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        url_status_code = self.get_link_status_code("https://torqata.com/")
        assert url_status_code == 200
        # User Click the  SIGN IN button
        self.click("//a[contains(text(),'Sign In')]")
        self.switch_to_window(1)
        # User Press on EMIL box and enter invalid email
        self.click("//input[@name='username']")
        self.input("//input[@name='username']", '<EMAIL>')
        # User Press on PASSWORD box and enter invalid password
        self.click("//input[@name='password']")
        self.input("//input[@name='password']", '<EMAIL>')
        # User Click the  Sign In button
        self.is_text_visible("Sign In", "//span[contains(text(),'Sign In')]")
        self.click("//span[contains(text(),'Sign In')]")
        invalid_credentials = self.get_text("//div[contains(text(),'Login Error: Invalid credentials.')]")
        assert "Login Error: Invalid credentials.", invalid_credentials
        print(invalid_credentials)
        print("\nEnd To End Test ---Test Id 00003 passed")

    # End To End Test ---Test Id 00004
    def test_torqata_00004(self):
        # User Go to https://torqata.com/
        self.open("https://torqata.com/")
        # User Click the  ‘Solutions’ dropdown
        self.click('//header//div[2]/ul[1]/li[1]/a[1]')
        # User Click on  ‘Profit Experts’ option
        self.click("//a[contains(text(),'Profit Expert')]")
        # Should be able to click YouTube play button
        # User check video plays 1:36 min
        profit_expert = self.get_text("//h3[contains(text(),'Profit Expert')]")
        assert "Profit Expert", profit_expert
        profit_expert_youtube_url = self.get_attribute("//*[@id='product-section-id']"
                                                       "/div/div[2]/div[2]/div[2]/iframe", 'src')
        status_code = self.get_link_status_code(profit_expert_youtube_url)
        if status_code == 200:
            print('\nProfit Expert video is ok')
        self.open('https://www.youtube.com/watch?v=gnX_aKL8DDg')
        self.click("//*[@id='movie_player']/div[24]/div[2]/div[1]/button")
        self.click("//*[@id='movie_player']/div[24]/div[2]/div[1]/button")
        # User click on  setting icon
        self.click("//div[@id='movie_player']/div[24]/div[2]/div[2]/button[3]")
        # User click on Quality
        self.click("//div[@id='ytp-id-17']/div/div/div[3]/div[3]/div")
        # User select on 720p
        self.click("//div[@id='ytp-id-17']/div/div[2]/div[2]/div/div")
        self.sleep(4)
        print("\nEnd To End Test ---Test Id 00004 passed")

    # END TO END TEST 00005----Test id 00005
    def test_torqata_00005(self):
        # Users Go to https://torqata.com/
        self.open("https://torqata.com/")
        # Users Click the  ‘Resources’ dropdown
        self.click("//a[contains(text(),'Resources')]")
        # Users Click on  ‘Blog’ option
        self.click("//div/a[1][contains(text(),'Blog')]")
        # Users scroll link into view and click link on  Podcast: Building Flask APIs for data scientists
        self.scroll_to("//a[contains(text(),'Podcast: Building Flask APIs for data scientists')]")
        self.click("//a[contains(text(),'Podcast: Building Flask APIs for data scientists')]")
        # Users verify text ‘By Author: <NAME>’ visible
        self.assert_element_present("//span[contains(text(),'<NAME>')]")
        # Users verifies text “Featuring: <NAME>” is present
        self.assert_element_present("//a[contains(text(),'<NAME>')]")
        # Users click on link podcast link
        self.click("//a[contains(text(),'https://talkpython.fm/episodes/show/226/building-flask-apis-for-data"
                   "-scientists')]")
        self.switch_to_window(1)
        # Users Verify the name <NAME> in podcast site
        self.assert_element_present("//div[1][contains(text(),'<NAME>')]")
        guest = self.get_text("//div[1][contains(text(),'<NAME>')]")
        assert guest == '<NAME>'
        print("\nEND TO END TEST 00005----Test id 00005 passed")
# UNIT TEST 00001----Test id 00001 # User Go to https://torqata.com/ # User Click the  SIGN IN button # User Press on EMIL box and enter invalid email #$%^&*()_+-') # INTEGRATION TEST 00002----Test id 00002 # User Go to https://torqata.com/ # User Click the  SIGN IN button # User Press on EMIL box and enter invalid email #$%^&*()_+-') # User Press on PASSWORD box and enter any password #$%^&*()_+-') # End To End Test ---Test Id 00003 # User Go to https://torqata.com/ # User Click the  SIGN IN button # User Press on EMIL box and enter invalid email # User Press on PASSWORD box and enter invalid password # User Click the  Sign In button # End To End Test ---Test Id 00004 # User Go to https://torqata.com/ # User Click the  ‘Solutions’ dropdown # User Click on  ‘Profit Experts’ option # Should be able to click YouTube play button # User check video plays 1:36 min # User click on  setting icon # User click on Quality # User select on 720p # END TO END TEST 00005----Test id 00005 # Users Go to https://torqata.com/ # Users Click the  ‘Resources’ dropdown # Users Click on  ‘Blog’ option # Users scroll link into view and click link on  Podcast: Building Flask APIs for data scientists # Users verify text ‘By Author: <NAME>’ visible # Users verifies text “Featuring: <NAME>” is present # Users click on link podcast link # Users Verify the name <NAME> in podcast site