def setUp(self):
        self.vars = {'my_xpath_locator': '/html/body/div[3]', 'name': 'Name', 'red_pill': 'take_it,'}

        timeout = 3.5
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file', '/somewhere/webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(timeout)
        self.wnd_mng = WindowManager()
        self.frm_mng = FrameManager()
        apiritif.put_into_thread_store(func_mode=False, scenario_name='loc_sc', driver=self.driver, timeout=timeout)
Пример #2
0
 def setUp(self):
     self.driver = None
     options = webdriver.FirefoxOptions()
     profile = webdriver.FirefoxProfile()
     profile.set_preference('webdriver.log.file', '<somewhere>webdriver.log')
     self.driver = webdriver.Firefox(profile, firefox_options=options)
     self.driver.implicitly_wait(3.5)
     self.wnd_mng = WindowManager(self.driver)
     self.frm_mng = FrameManager(self.driver)
     self.loc_mng = LocatorsManager(self.driver)
     self.vars = {
         'name': 'Name',
         'red_pill': 'take_it',
     }
     apiritif.put_into_thread_store(func_mode=False, driver=self.driver)
Пример #3
0
def setup():
    options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(service_log_path='<somewhere>webdriver.log',
                              chrome_options=options)
    driver.implicitly_wait(3.5)
    wnd_mng = WindowManager(driver)
    frm_mng = FrameManager(driver)
    vars = {}
    apiritif.put_into_thread_store(vars, driver, wnd_mng, frm_mng)
Пример #4
0
 def setUp(self):
     self.vars = {
         'name': 'Name',
         'red_pill': 'take_it',
     }
     reader_1.read_vars()
     reader_2.read_vars()
     self.vars.update(reader_1.get_vars())
     self.vars.update(reader_2.get_vars())
     self.driver = None
     options = webdriver.FirefoxOptions()
     profile = webdriver.FirefoxProfile()
     profile.set_preference('webdriver.log.file', '/somewhere/webdriver.log')
     self.driver = webdriver.Firefox(profile, firefox_options=options)
     self.driver.implicitly_wait(3.5)
     self.wnd_mng = WindowManager(self.driver)
     self.frm_mng = FrameManager(self.driver)
     self.loc_mng = LocatorsManager(self.driver, 3.5)
     apiritif.put_into_thread_store(func_mode=True, driver=self.driver,scenario_name='loc_sc', data_sources=True)
Пример #5
0
    def setUp(self):
        self.vars = {'name': 'Name', 'red_pill': 'take_it'}
        reader_1.read_vars()
        reader_2.read_vars()
        self.vars.update(reader_1.get_vars())
        self.vars.update(reader_2.get_vars())

        timeout = 3.5
        self.driver = None
        options = webdriver.FirefoxOptions()
        options.set_preference('network.proxy.type', '4')
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file', '/somewhere/webdriver.log')
        self.driver = webdriver.Firefox(profile, options=options)
        self.driver.implicitly_wait(timeout)
        self.wnd_mng = WindowManager()
        self.frm_mng = FrameManager()
        apiritif.put_into_thread_store(data_sources=True, timeout=timeout, scenario_name='loc_sc', driver=self.driver,
                                       func_mode=True)
Пример #6
0
def setup():
    driver = webdriver.Remote(command_executor='http://localhost:4723/wd/hub',
                              desired_capabilities={
                                  'browserName': 'chrome',
                                  'deviceName': '',
                                  'platformName': 'android',
                              })
    driver.implicitly_wait(3.5)
    wnd_mng = WindowManager(driver)
    frm_mng = FrameManager(driver)
    vars = {}
    apiritif.put_into_thread_store(vars, driver, wnd_mng, frm_mng)
Пример #7
0
def setup():
    options = webdriver.FirefoxOptions()
    profile = webdriver.FirefoxProfile()
    profile.set_preference('webdriver.log.file', '<somewhere>webdriver.log')
    driver = webdriver.Firefox(profile, firefox_options=options)
    driver.implicitly_wait(3.5)
    wnd_mng = WindowManager(driver)
    frm_mng = FrameManager(driver)
    vars = {
        'name': 'Name',
        'red_pill': 'take_it',
    }
    apiritif.put_into_thread_store(vars, driver, wnd_mng, frm_mng)
Пример #8
0
def setup():
    driver = webdriver.Remote(
        command_executor='http://*****:*****@remote_web_driver_host:port/wd/hub',
        desired_capabilities={
            'app': '',
            'browserName': 'firefox',
            'deviceName': '',
            'javascriptEnabled': 'True',
            'platformName': 'linux',
            'platformVersion': '',
            'seleniumVersion': '',
            'version': '54.0',
        })
    driver.implicitly_wait(3.5)
    wnd_mng = WindowManager(driver)
    frm_mng = FrameManager(driver)
    vars = {}
    apiritif.put_into_thread_store(vars, driver, wnd_mng, frm_mng)
Пример #9
0
class TestLocSc(unittest.TestCase):
    def setUp(self):
        self.vars = {'name': 'Name', 'red_pill': 'take_it'}
        reader_1.read_vars()
        reader_2.read_vars()
        self.vars.update(reader_1.get_vars())
        self.vars.update(reader_2.get_vars())

        timeout = 3.5
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file',
                               '/somewhere/webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(timeout)
        self.wnd_mng = WindowManager()
        self.frm_mng = FrameManager()
        apiritif.put_into_thread_store(scenario_name='loc_sc',
                                       timeout=timeout,
                                       driver=self.driver,
                                       func_mode=True,
                                       data_sources=True)

    def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')
            dialogs_replace()

            var_loc_wait = get_locator([{'xpath': "//input[@type='submit']"}])
            WebDriverWait(self.driver, 3.5).until(
                econd.presence_of_element_located(
                    (var_loc_wait[0], var_loc_wait[1])),
                'Element \'xpath\':"//input[@type=\'submit\']" failed to appear within 3.5s'
            )
            self.assertEqual(self.driver.title, 'BlazeDemo')

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[2]/div/p[2]/a'
            }])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{'xpath': '/html/body/div[3]/h2'}])
            ActionChains(self.driver).double_click(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[3]/form/select[1]'
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{
                'xpath':
                '/html/body/div[3]/form/select[1]/option[6]'
            }])
            ActionChains(self.driver).release(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_select = get_locator([{'name': 'toPort'}])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text('London')

            var_loc_keys = get_locator([{'css': 'body input.btn.btn-primary'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_as = get_locator([{'id': 'address'}])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                '123 Beautiful st.'.strip())

            var_loc_as = get_locator([{
                'xpath':
                '/html/body/div[2]/form/div[1]/label'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                self.vars['name'].strip())

            var_loc_wait = get_locator([{'name': 'toPort'}])
            WebDriverWait(self.driver, 3.5).until(
                econd.visibility_of_element_located(
                    (var_loc_wait[0], var_loc_wait[1])),
                "Element 'name':'toPort' failed to appear within 3.5s")

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('B')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('B')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{
                'xpath':
                '//div[3]/form/select[1]//option[3]'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            var_loc_keys = get_locator([{
                'xpath':
                '//div[3]/form/select[2]//option[6]'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()
            self.wnd_mng.switch('0')
            self.driver.execute_script("window.open('some.url');")
            self.wnd_mng.switch('win_ser_local')
            self.wnd_mng.switch('win_ser_1')
            self.wnd_mng.switch('that_window')
            self.wnd_mng.close('1')
            self.wnd_mng.close('win_ser_local')
            self.wnd_mng.close('win_ser_1')
            self.wnd_mng.close('that_window')

            var_loc_keys = get_locator([{'name': 'toPort'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).submit()
            self.driver.execute_script("alert('This is Sparta');")

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)

            source = get_locator([{'id': 'address'}])

            target = get_locator([{'name': 'toPort'}])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()
            self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame'))
            self.frm_mng.switch('index=1')
            self.frm_mng.switch('relative=parent')

            var_edit_content = get_locator([{'id': 'editor'}])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            sleep(3.5)
            self.driver.delete_all_cookies()

            var_loc_keys = get_locator([{
                'linktext':
                'destination of the week! The Beach!'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            self.vars['Title'] = self.driver.title

            var_loc_as = get_locator([{'xpath': "//*[@id='basics']/h2"}])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')

            var_loc_as = get_locator([{'xpath': "//*[@id='basics']/h1"}])

            self.vars['World'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('value')

            self.vars['Final'] = '{} {} by {}'.format(self.vars['Title'],
                                                      self.vars['Basic'],
                                                      self.vars['By'])

            self.vars['var_eval'] = self.driver.execute_script(
                'return 0 == false;')
            self.assertTrue(self.driver.execute_script('return 10 === 2*5;'),
                            '10 === 2*5')
            self.driver.get('http:\\blazemeter.com')

            dialogs_replace()

            dialog = dialogs_get_next_alert()
            self.assertIsNotNone(dialog, 'No dialog of type alert appeared')
            self.assertEqual(dialog, 'Alert Message',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_prompt()
            self.assertIsNotNone(dialog, 'No dialog of type prompt appeared')
            self.assertEqual(dialog, 'Enter value',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_confirm()
            self.assertIsNotNone(dialog, 'No dialog of type confirm appeared')
            self.assertEqual(dialog, 'Are you sure?',
                             "Dialog message didn't match")
            dialogs_answer_on_next_prompt('myvalue')
            dialogs_answer_on_next_confirm('#Ok')
            dialogs_answer_on_next_alert('#Ok')
            print(self.vars['red_pill'])
            self.driver.save_screenshot('screen.png')

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            body = self.driver.page_source
            re_pattern = re.compile('contained_text')
            self.assertEqual(0, len(re.findall(re_pattern, body)),
                             "Assertion: 'contained_text' found in BODY")

    def _2_empty(self):
        with apiritif.smart_transaction('empty'):
            pass

    def test_locsc(self):
        self._1_()
        self._2_empty()

    def tearDown(self):
        if self.driver:
            self.driver.quit()
Пример #10
0
class TestLocSc(unittest.TestCase):
    def setUp(self):
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file',
                               '/somewhere/webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(3.5)
        self.wnd_mng = WindowManager(self.driver)
        self.frm_mng = FrameManager(self.driver)
        self.loc_mng = LocatorsManager(self.driver, 3.5)
        self.vars = {
            'name': 'Name',
            'red_pill': 'take_it,',
        }
        apiritif.put_into_thread_store(func_mode=False, driver=self.driver)

    def _1_Test_V2(self):
        with apiritif.smart_transaction('Test V2'):
            self.driver.get('http://blazedemo.com')
            self.driver.set_window_size('750', '750')
            self.wnd_mng.switch(0)

            var_loc_chain = self.loc_mng.get_locator([{
                'id': 'invalid_id',
            }, {
                'xpath':
                '/html/body/div[3]/form/select[1]',
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = self.loc_mng.get_locator([{
                'id': 'id_123',
            }])
            ActionChains(self.driver).move_to_element_with_offset(
                self.driver.find_element(var_loc_chain[0], var_loc_chain[1]),
                -10, -10).perform()

            var_loc_chain = self.loc_mng.get_locator([{
                'name': 'name_123',
            }])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            source = self.loc_mng.get_locator([{
                'name': 'invalid_name',
            }, {
                'xpath':
                '/html/body/div[2]/div/p[2]/a',
            }])

            target = self.loc_mng.get_locator([{
                'css': 'invalid_css',
            }, {
                'xpath':
                '/html/body/div[3]/form/div',
            }])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()

            var_loc_as = self.loc_mng.get_locator([{
                'css': 'myclass',
            }, {
                'xpath':
                '/html/body/div[3]/h2',
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                'Choose your departure city:'.strip())

            var_loc_as = self.loc_mng.get_locator([{
                'css': 'myclass',
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input',
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                'Find Flights'.strip())
            self.assertEqual(self.driver.title, 'BlazeDemo')

            self.vars['hEaDeR'] = self.driver.title

            self.vars['final_var'] = 'test_text'

            var_loc_as = self.loc_mng.get_locator([{
                'xpath':
                '/html/body/div[3]/h2',
            }])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')

            var_loc_keys = self.loc_mng.get_locator([{
                'xpath': '/wrong/one',
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input',
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            var_loc_keys = self.loc_mng.get_locator([{
                'xpath': '/doc/abc',
            }, {
                'css':
                'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input',
            }])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = self.loc_mng.get_locator([{
                'id': 'fjkafjk',
            }, {
                'css': 'testCss',
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('myusername')

            var_loc_select = self.loc_mng.get_locator([{
                'css': 'myclass',
            }, {
                'xpath':
                '//*[@id="cardType"]',
            }])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text(
                        'American Express')
            self.driver.execute_script(
                'window.scrollTo(0, document.body.scrollHeight);')

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)
            print(self.vars['red_pill'])
            sleep(4.6)
            self.driver.delete_all_cookies()
            self.driver.save_screenshot('screen.png')

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)

            var_loc_wait = self.loc_mng.get_locator([{
                'css': 'invalid_css',
            }, {
                'name': 'inputName',
            }])
            WebDriverWait(self.driver, 3.5).until(
                econd.visibility_of_element_located(
                    (var_loc_wait[0], var_loc_wait[1])),
                "Element 'css':'invalid_css' failed to appear within 3.5s")

            var_edit_content = self.loc_mng.get_locator([{
                'id': 'editor',
            }])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            sleep(4.6)
            self.driver.delete_all_cookies()
            self.driver.save_screenshot('screen.png')

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            self.driver.execute_script("window.open('vacation.html');")
            self.driver.maximize_window()
            self.frm_mng.switch('index=1')
            self.frm_mng.switch('relative=parent')
            self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame'))
            self.wnd_mng.close()

    def test_locsc(self):
        self._1_Test_V2()

    def tearDown(self):
        if self.driver:
            self.driver.quit()
Пример #11
0
class TestLocSc(unittest.TestCase):
    def setUp(self):
        self.vars = {
            'my_xpath_locator': '/html/body/div[3]',
            'name': 'Name',
            'red_pill': 'take_it,'
        }

        timeout = 3.5
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file',
                               '/somewhere/webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(timeout)
        self.wnd_mng = WindowManager()
        self.frm_mng = FrameManager()
        apiritif.put_into_thread_store(driver=self.driver,
                                       scenario_name='loc_sc',
                                       timeout=timeout,
                                       func_mode=False)

    def _1_Test_V2(self):
        with apiritif.smart_transaction('Test V2'):
            self.driver.get('http://blazedemo.com')

            dialogs_replace()
            self.driver.set_window_size('750', '750')
            self.wnd_mng.switch(0)

            var_loc_chain = get_locator([{
                'id': 'invalid_id'
            }, {
                'xpath': self.vars['my_xpath_locator']
            }])
            ActionChains(self.driver).click_and_hold(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            var_loc_chain = get_locator([{'id': 'id_123'}])
            ActionChains(self.driver).move_to_element_with_offset(
                self.driver.find_element(var_loc_chain[0], var_loc_chain[1]),
                -10, -10).perform()

            var_loc_chain = get_locator([{'name': 'name_123'}])
            ActionChains(self.driver).move_to_element(
                self.driver.find_element(var_loc_chain[0],
                                         var_loc_chain[1])).perform()

            source = get_locator([{
                'name': 'invalid_name'
            }, {
                'xpath': '/html/body/div[2]/div/p[2]/a'
            }])

            target = get_locator([{
                'css': 'invalid_css'
            }, {
                'xpath': '/html/body/div[3]/form/div'
            }])
            ActionChains(self.driver).drag_and_drop(
                self.driver.find_element(source[0], source[1]),
                self.driver.find_element(target[0], target[1])).perform()

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '/html/body/div[3]/h2'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('innerText').strip(),
                'Choose your departure city:'.strip())

            var_loc_as = get_locator([{
                'css': 'myclass'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.assertEqual(
                self.driver.find_element(
                    var_loc_as[0],
                    var_loc_as[1]).get_attribute('value').strip(),
                'Find Flights'.strip())
            self.assertEqual(self.driver.title, 'BlazeDemo')

            self.vars['hEaDeR'] = self.driver.title

            self.vars['final_var'] = 'test_text'

            var_loc_as = get_locator([{'xpath': '/html/body/div[3]/h2'}])

            self.vars['Basic'] = self.driver.find_element(
                var_loc_as[0], var_loc_as[1]).get_attribute('innerText')
            self.assertTrue(self.driver.execute_script('return 10 === 2*5;'),
                            '10 === 2*5')

            self.vars['var_eval'] = self.driver.execute_script(
                'return 0 == false;')

            var_loc_keys = get_locator([{
                'xpath': '/wrong/one'
            }, {
                'xpath':
                '/html/body/div[3]/form/div/input'
            }])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).click()

            var_loc_keys = get_locator([{
                'xpath': '/doc/abc'
            }, {
                'css':
                'body > div.container > table > tbody > tr:nth-child(1) > td:nth-child(2) > input'
            }])
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys(Keys.ENTER)

            var_loc_keys = get_locator([{'id': 'fjkafjk'}, {'css': 'testCss'}])
            self.driver.find_element(var_loc_keys[0], var_loc_keys[1]).clear()
            self.driver.find_element(var_loc_keys[0],
                                     var_loc_keys[1]).send_keys('myusername')

            var_loc_select = get_locator([{
                'css': 'myclass'
            }, {
                'xpath': '//*[@id="cardType"]'
            }])
            Select(
                self.driver.find_element(
                    var_loc_select[0],
                    var_loc_select[1])).select_by_visible_text(
                        'American Express')
            self.driver.execute_script(
                'window.scrollTo(0, document.body.scrollHeight);')

            for i in range(10):
                if ((i % 2) == 0):
                    print(i)
            print(self.vars['red_pill'])
            sleep(4.6)
            self.driver.delete_all_cookies()
            self.driver.save_screenshot('screen.png')

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            wait_for('visible', [{
                'css': 'invalid_css'
            }, {
                'name': 'inputName'
            }], 3.5)
            wait_for('visible', [{
                'css': 'invalid_css'
            }, {
                'name': 'inputName'
            }], 9020.0)

            var_edit_content = get_locator([{'id': 'editor'}])

            if self.driver.find_element(
                    var_edit_content[0],
                    var_edit_content[1]).get_attribute('contenteditable'):
                self.driver.execute_script(
                    ("arguments[0].innerHTML = '%s';" % 'lo-la-lu'),
                    self.driver.find_element(var_edit_content[0],
                                             var_edit_content[1]))
            else:
                raise NoSuchElementException(
                    ('The element (%s: %r) is not a contenteditable element' %
                     (var_edit_content[0], var_edit_content[1])))
            sleep(4.6)
            self.driver.delete_all_cookies()
            self.driver.save_screenshot('screen.png')

            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'),
                                    ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            self.driver.execute_script("window.open('vacation.html');")
            self.driver.maximize_window()
            self.frm_mng.switch('index=1')
            self.frm_mng.switch('relative=parent')
            self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame'))
            self.wnd_mng.close()
            dialogs_answer_on_next_prompt('my input')
            dialogs_answer_on_next_confirm('#Ok')
            dialogs_answer_on_next_alert('#Ok')

            dialog = dialogs_get_next_alert()
            self.assertIsNotNone(dialog, 'No dialog of type alert appeared')
            self.assertEqual(dialog, 'Exception occurred!',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_confirm()
            self.assertIsNotNone(dialog, 'No dialog of type confirm appeared')
            self.assertEqual(dialog, 'Are you sure?',
                             "Dialog message didn't match")

            dialog = dialogs_get_next_prompt()
            self.assertIsNotNone(dialog, 'No dialog of type prompt appeared')
            self.assertEqual(dialog, 'What is your age?',
                             "Dialog message didn't match")

    def test_locsc(self):
        self._1_Test_V2()

    def tearDown(self):
        if self.driver:
            self.driver.quit()
class TestLocSc(unittest.TestCase, ):
    def setUp(self):
        self.driver = None
        options = webdriver.FirefoxOptions()
        profile = webdriver.FirefoxProfile()
        profile.set_preference('webdriver.log.file', '<somewhere>webdriver.log')
        self.driver = webdriver.Firefox(profile, firefox_options=options)
        self.driver.implicitly_wait(3.5)
        self.wnd_mng = WindowManager(self.driver)
        self.frm_mng = FrameManager(self.driver)

        self.vars = {
            'name': 'Name',
            'red_pill': 'take_it',
        }

        apiritif.put_into_thread_store(driver=self.driver, func_mode=False)


    def _1_(self):
        with apiritif.smart_transaction('/'):
            self.driver.get('http://blazedemo.com/')
            WebDriverWait(self.driver, 3.5).until(econd.presence_of_element_located((By.XPATH, "//input[@type='submit']")), 'Element "//input[@type=\'submit\']" failed to appear within 3.5s')
            self.assertEqual(self.driver.title, 'BlazeDemo')
            ActionChains(self.driver).move_to_element(self.driver.find_element(By.XPATH, '/html/body/div[2]/div/p[2]/a')).perform()
            ActionChains(self.driver).double_click(self.driver.find_element(By.XPATH, '/html/body/div[3]/h2')).perform()
            ActionChains(self.driver).click_and_hold(self.driver.find_element(By.XPATH, '/html/body/div[3]/form/select[1]')).perform()
            ActionChains(self.driver).release(self.driver.find_element(By.XPATH, '/html/body/div[3]/form/select[1]/option[6]')).perform()
            Select(self.driver.find_element(By.NAME, 'toPort')).select_by_visible_text('London')
            self.driver.find_element(By.CSS_SELECTOR, 'body input.btn.btn-primary').send_keys(Keys.ENTER)
            self.assertEqual(self.driver.find_element(By.ID, 'address').get_attribute('value').strip(), '123 Beautiful st.'.strip())
            self.assertEqual(self.driver.find_element(By.XPATH, '/html/body/div[2]/form/div[1]/label').get_attribute('innerText').strip(), self.vars['name'].strip())
            WebDriverWait(self.driver, 3.5).until(econd.visibility_of_element_located((By.NAME, 'toPort')), "Element 'toPort' failed to appear within 3.5s")
            self.driver.find_element(By.NAME, 'toPort').send_keys('B')
            self.driver.find_element(By.NAME, 'toPort').clear()
            self.driver.find_element(By.NAME, 'toPort').send_keys('B')
            self.driver.find_element(By.NAME, 'toPort').send_keys(Keys.ENTER)
            self.driver.find_element(By.NAME, 'toPort').clear()
            self.driver.find_element(By.NAME, 'toPort').send_keys(Keys.ENTER)
            self.driver.find_element(By.XPATH, '//div[3]/form/select[1]//option[3]').click()
            self.driver.find_element(By.XPATH, '//div[3]/form/select[2]//option[6]').click()
            self.wnd_mng.switch('0')
            self.driver.execute_script("window.open('some.url');")
            self.wnd_mng.switch('win_ser_local')
            self.wnd_mng.switch('win_ser_1')
            self.wnd_mng.switch('that_window')
            self.wnd_mng.close('1')
            self.wnd_mng.close('win_ser_local')
            self.wnd_mng.close('win_ser_1')
            self.wnd_mng.close('that_window')
            self.driver.find_element(By.NAME, 'toPort').submit()
            self.driver.execute_script("alert('This is Sparta');")
            
            for i in range(10):
                if ((i % 2) == 0):
                    print(i)
            ActionChains(self.driver).drag_and_drop(self.driver.find_element(By.ID, 'address'), self.driver.find_element(By.NAME, 'toPort')).perform()
            self.frm_mng.switch(self.driver.find_element(By.NAME, 'my_frame'))
            self.frm_mng.switch('index=1')
            self.frm_mng.switch('relative=parent')
            
            if self.driver.find_element(By.ID, 'editor').get_attribute('contenteditable'):
                self.driver.execute_script(('arguments[0].innerHTML = %s;' % 'lo-la-lu'), self.driver.find_element(By.ID, 'editor'))
            else:
                raise NoSuchElementException("The element (By.ID, 'editor') is not contenteditable element")
            sleep(3.5)
            self.driver.delete_all_cookies()
            self.driver.find_element(By.LINK_TEXT, 'destination of the week! The Beach!').click()
            
            self.vars['Title'] = self.driver.title
            
            self.vars['Basic'] = self.driver.find_element(By.XPATH, "//*[@id='basics']/h2").get_attribute('innerText')
            
            self.vars['World'] = self.driver.find_element(By.XPATH, "//*[@id='basics']/h1").get_attribute('value')
            
            self.vars['Final'] = '{} {} by {}'.format(self.vars['Title'], self.vars['Basic'], self.vars['By'])
            self.driver.get('http:\\blazemeter.com')
            print(self.vars['red_pill'])
            self.driver.save_screenshot('screen.png')
            
            filename = os.path.join(os.getenv('TAURUS_ARTIFACTS_DIR'), ('screenshot-%d.png' % (time() * 1000)))
            self.driver.save_screenshot(filename)
            body = self.driver.page_source
            re_pattern = re.compile('contained_text')
            self.assertEqual(0, len(re.findall(re_pattern, body)), "Assertion: 'contained_text' found in BODY")

    def _2_empty(self):
        with apiritif.smart_transaction('empty'):
            pass

    def test_locsc(self):
        self._1_()
        self._2_empty()

    def tearDown(self):
        if self.driver:
            self.driver.quit()