Best Python code snippet using SeleniumBase
test_test_steps.py
Source:test_test_steps.py
...110 self.assertEqual(assert_attribute.css_path, ANY_CSS_PATH)111 self.assertEqual(assert_attribute.hint, ANY_HINT)112 self.assertEqual(assert_attribute.attribute_name, ANY_ATTRIBUTE_NAME)113 self.assertEqual(assert_attribute.expected_value, ANY_VALUE)114 def test_run_assert_attribute(self):115 driver_testable = DriverTestable()116 assert_attribute = any_assert_attribute()117 with patch.object(driver_testable, 'get_element_attribute', return_value=assert_attribute.expected_value) \118 as driver_mock:119 step_result = assert_attribute.run(driver_testable)120 driver_mock.assert_called_with(assert_attribute.css_path, assert_attribute.hint,121 assert_attribute.attribute_name)122 self.assertTrue(step_result.success)123 self.assertEqual(step_result.step, assert_attribute)124 def test_run_assert_attribute_different_values(self):125 driver_testable = DriverTestable()126 assert_attribute = any_assert_attribute()127 with patch.object(driver_testable, 'get_element_attribute', return_value=ANY_OTHER_VALUE) \128 as assert_value_mock:129 assert_attribute = any_assert_attribute()130 step_result = assert_attribute.run(driver_testable)131 assert_value_mock.assert_called_with(assert_attribute.css_path, assert_attribute.hint,132 assert_attribute.attribute_name)133 self.assertFalse(step_result.success)134 self.assertEqual(step_result.step, assert_attribute)135 assertion_exception = step_result.exception136 self.assertEqual(assertion_exception.css_path, assert_attribute.css_path)137 self.assertEqual(assertion_exception.hint, assert_attribute.hint)138 self.assertEqual(assertion_exception.attribute_name, assert_attribute.attribute_name)139 self.assertEqual(assertion_exception.expected_value, assert_attribute.expected_value)140 self.assertEqual(assertion_exception.actual_value, ANY_OTHER_VALUE)141 def test_run_assert_attribute_exception(self):142 driver_testable = DriverTestable()143 assert_attribute = any_assert_attribute()144 with patch.object(driver_testable, 'get_element_attribute', return_value=assert_attribute.expected_value) \145 as assert_value_mock:146 exception = Exception()147 assert_value_mock.side_effect = exception148 step_result = assert_attribute.run(driver_testable)149 assert_value_mock.assert_called_with(assert_attribute.css_path, assert_attribute.hint,150 assert_attribute.attribute_name)151 self.assertFalse(step_result.success)152 self.assertEqual(step_result.step, assert_attribute)153 self.assertEqual(step_result.exception, exception)154class TestAssertElementValue(TestCase):155 """Has unit tests for the AssertElementValue class"""156 def test_initializer(self):157 assert_element = AssertElementValue(ANY_CSS_PATH, ANY_HINT, ANY_VALUE)...
test_confirmation.py
Source:test_confirmation.py
...166 '-7': 'Excede lÃmite diario por transacción.',167 '-8': 'Rubro no autorizado.'168 }169 for i in RESPONSE_CODES.keys():170 self.assert_attribute(171 RESPONSE_CODES[i],172 'message',173 TBK_RESPUESTA=str(i)174 )175 def test_response(self):176 for i in range(0, -9):177 self.assert_attribute(178 i,179 'response',180 TBK_RESPUESTA=str(i)181 )182 def test_paid_at(self):183 santiago = pytz.timezone('America/Santiago')184 today = santiago.localize(datetime.datetime.today())185 today = today - datetime.timedelta(microseconds=today.microsecond)186 self.assert_attribute(187 today,188 'paid_at',189 TBK_FECHA_TRANSACCION=today.strftime("%m%d"),190 TBK_HORA_TRANSACCION=today.strftime("%H%M%S"),191 )192 def test_amount(self):193 self.assert_attribute(194 Decimal("12345.00"),195 'amount',196 TBK_MONTO='1234500'197 )198 def test_amount_decimals(self):199 self.assert_attribute(200 Decimal("12345.67"),201 'amount',202 TBK_MONTO='1234567'203 )204 def test_transaction_id(self):205 transaction_id = 1234500206 self.assert_attribute(207 transaction_id,208 'transaction_id',209 TBK_ID_TRANSACCION=str(transaction_id)210 )211 def test_order_id(self):212 orden_compra = '123aSd4500'213 self.assert_attribute(214 orden_compra,215 'order_id',216 TBK_ORDEN_COMPRA=orden_compra217 )218 def test_credit_card_last_digits(self):219 self.assert_attribute(220 '9509',221 'credit_card_last_digits',222 TBK_FINAL_NUMERO_TARJETA='9509'223 )224 def test_credit_card_number(self):225 self.assert_attribute(226 'XXXX-XXXX-XXXX-9509', 'credit_card_number',227 TBK_FINAL_NUMERO_TARJETA='9509'228 )229 def test_authorization_code(self):230 authorization_code = '000123456'231 self.assert_attribute(232 authorization_code,233 'authorization_code',234 TBK_CODIGO_AUTORIZACION=authorization_code235 )236 def test_accountable_date(self):237 santiago = pytz.timezone('America/Santiago')238 today = datetime.date.today()239 today = santiago.localize(240 datetime.datetime(today.year, today.month, today.day))241 self.assert_attribute(242 today,243 'accountable_date',244 TBK_FECHA_CONTABLE=today.strftime("%m%d"),245 TBK_FECHA_TRANSACCION=today.strftime("%m%d"),246 TBK_HORA_TRANSACCION=today.strftime("%H%M%S"),247 )248 def test_accountable_date_next_year(self):249 santiago = pytz.timezone('America/Santiago')250 today = santiago.localize(datetime.datetime.today())251 year = today.year252 santiago = pytz.timezone('America/Santiago')253 transaction_date = datetime.datetime(year, 12, 31, 11, 59, 59)254 accountable_date = datetime.datetime(year + 1, 1, 2)255 expected = santiago.localize(accountable_date)256 self.assert_attribute(257 expected,258 'accountable_date',259 TBK_FECHA_CONTABLE=accountable_date.strftime("%m%d"),260 TBK_FECHA_TRANSACCION=transaction_date.strftime("%m%d"),261 TBK_HORA_TRANSACCION=transaction_date.strftime("%H%M%S"),262 )263 def test_session_id(self):264 session_id = 'asdb1234asdQwe'265 self.assert_attribute(266 session_id,267 'session_id',268 TBK_ID_SESION=session_id269 )270 def test_session_id_null(self):271 self.assert_attribute(272 None,273 'session_id',274 TBK_ID_SESION="null"275 )276 def test_installments(self):277 for i in range(42):278 self.assert_attribute(279 i,280 'installments',281 TBK_NUMERO_CUOTAS=str(i)282 )283 def test_payment_type_code(self):284 for code in ("VN", "VC", "SI", "S2", "CI"):285 self.assert_attribute(286 code,287 'payment_type_code',288 TBK_TIPO_PAGO=code289 )290 def test_payment_type(self):291 PAYMENT_TYPES = {292 "VN": "Venta Normal",293 "VC": "Venta Cuotas",294 "SI": "Tres Cuotas Sin Interés",295 "S2": "Dos Cuotas Sin Interés",296 "CI": "Cuotas Comercio",297 "VD": "Redcompra",298 }299 for code in PAYMENT_TYPES.keys():300 self.assert_attribute(301 PAYMENT_TYPES[code],302 'payment_type',303 TBK_TIPO_PAGO=code304 )305 def test_get_item(self):306 payload = ConfirmationPayload(CONFIRMATION_DATA)307 for key, value in CONFIRMATION_DATA.items():308 self.assertEqual(value, payload[key])309 def assert_attribute(self, expected, attribute, **data):310 payload = ConfirmationPayload(data)311 result = getattr(payload, attribute)312 self.assertEqual(313 expected,314 result,315 '{attribute} not equal to {expected} but {result}'.format(316 attribute=attribute,317 expected=expected,318 result=result319 )...
test_htmlparser.py
Source:test_htmlparser.py
...51 self.assertEqual(["cls"], soup.a['class'])52 self.assertEqual("id", soup.a['id'])53 54 # You can also get this behavior explicitly.55 def assert_attribute(on_duplicate_attribute, expected):56 soup = self.soup(57 markup, on_duplicate_attribute=on_duplicate_attribute58 )59 self.assertEqual(expected, soup.a['href'])60 # Verify that non-duplicate attributes are treated normally.61 self.assertEqual(["cls"], soup.a['class'])62 self.assertEqual("id", soup.a['id'])63 assert_attribute(None, "url3")64 assert_attribute(BeautifulSoupHTMLParser.REPLACE, "url3")65 # You can ignore subsequent values in favor of the first.66 assert_attribute(BeautifulSoupHTMLParser.IGNORE, "url1")67 # And you can pass in a callable that does whatever you want.68 def accumulate(attrs, key, value):69 if not isinstance(attrs[key], list):70 attrs[key] = [attrs[key]]71 attrs[key].append(value)72 assert_attribute(accumulate, ["url1", "url2", "url3"]) 73class TestHTMLParserSubclass(SoupTest):74 def test_error(self):75 """Verify that our HTMLParser subclass implements error() in a way76 that doesn't cause a crash.77 """78 parser = BeautifulSoupHTMLParser()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!