How to use verify__execute_client_script_call method in pytractor

Best Python code snippet using pytractor_python

test_mixins.py

Source:test_mixins.py Github

copy

Full Screen

...87 self.mock_root_element = MagicMock()88 self.instance = WebDriverMixin('http://localhost',89 self.mock_root_element)90 @patch('pytractor.mixins.resource_string')91 def verify__execute_client_script_call(self, async, mock_resource_string):92 with patch.multiple(93 self.instance,94 execute_async_script=DEFAULT, execute_script=DEFAULT,95 create=True96 ) as mock_execute:97 (mock_execute_script,98 mock_execute_async_script) = [mock_execute.get(func_name)99 for func_name in100 ('execute_script',101 'execute_async_script')]102 mock_arg = MagicMock()103 result = self.instance._execute_client_script('SCRIPT', mock_arg,104 async=async)105 # the script was read correctly with resource_string()106 mock_resource_string.assert_called_once_with(107 'pytractor.mixins',108 '{}/{}.js'.format(CLIENT_SCRIPTS_DIR, 'SCRIPT')109 )110 # execute_async_script or execute_script were called (but not both)111 script_content = mock_resource_string.return_value.decode()112 if async:113 mock_execute_async_script.assert_called_once_with(script_content,114 mock_arg)115 self.assertEqual(len(mock_execute_script.mock_calls), 0)116 # the result is the one from execute_async_script()117 self.assertIs(result, mock_execute_async_script.return_value)118 else:119 mock_execute_script.assert_called_once_with(script_content,120 mock_arg)121 self.assertEqual(len(mock_execute_async_script.mock_calls), 0)122 # the result is the one from execute_script()123 self.assertIs(result, mock_execute_script.return_value)124 def test__execute_client_script_async(self):125 self.verify__execute_client_script_call(True)126 def test__execute_client_script_sync(self):127 self.verify__execute_client_script_call(False)128 def verify_function_executes_script_with(self, func_to_call,129 script_name, *script_args,130 **script_kwargs):131 with patch.object(132 self.instance, '_execute_client_script'133 ) as mock_execute_client_script:134 result = func_to_call()135 mock_execute_client_script.assert_called_once_with(136 script_name,137 *script_args, **script_kwargs138 )139 self.assertIs(result, mock_execute_client_script.return_value)140 def test_wait_for_angular(self):141 self.verify_function_executes_script_with(...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytractor automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful