How to use input_text method in robotframework-pageobjects

Best Python code snippet using robotframework-pageobjects_python

test_parsing.py

Source:test_parsing.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2from unittest import TestCase3from datetime import timedelta, datetime4from chatterbot import parsing5class DateTimeParsingFunctionIntegrationTestCases(TestCase):6 """7 Test the datetime parseing module.8 Output of the parser is an array of tuples9 [match, value, (start, end)]10 """11 def setUp(self):12 super(DateTimeParsingFunctionIntegrationTestCases, self).setUp()13 self.base_date = datetime.now()14 def test_captured_pattern_is_on_date(self):15 input_text = 'The event is on Monday 12 January 2012'16 parser = parsing.datetime_parsing(input_text)17 self.assertIn('Monday 12 January 2012', parser[0])18 self.assertEqual(parser[0][1], datetime(2012, 1, 12))19 self.assertEqual(len(parser), 1)20 def test_captured_pattern_this_weekday(self):21 input_text = 'This monday'22 parser = parsing.datetime_parsing(input_text)23 self.assertIn(input_text, parser[0])24 self.assertEqual(25 parser[0][1].strftime('%d-%m-%y'),26 parsing.this_week_day(self.base_date, 0).strftime('%d-%m-%y')27 )28 self.assertEqual(len(parser), 1)29 def test_captured_pattern_last_weekday(self):30 input_text = 'Last monday'31 parser = parsing.datetime_parsing(input_text)32 self.assertIn(input_text, parser[0])33 self.assertEqual(34 parser[0][1].strftime('%d-%m-%y'),35 parsing.previous_week_day(self.base_date, 0).strftime('%d-%m-%y')36 )37 self.assertEqual(len(parser), 1)38 def test_captured_pattern_next_weekday(self):39 input_text = 'Next monday'40 parser = parsing.datetime_parsing(input_text)41 self.assertIn(input_text, parser[0])42 self.assertEqual(43 parser[0][1].strftime('%d-%m-%y'),44 parsing.next_week_day(self.base_date, 0).strftime('%d-%m-%y')45 )46 self.assertEqual(len(parser), 1)47 def test_captured_pattern_minutes_from_now(self):48 input_text = '25 minutes from now'49 parser = parsing.datetime_parsing(input_text)50 self.assertIn(input_text, parser[0])51 self.assertEqual(52 parser[0][1].strftime('%d-%m-%y'),53 parsing.date_from_duration(54 self.base_date, 25, 'minutes', 'from now'55 ).strftime('%d-%m-%y')56 )57 self.assertEqual(len(parser), 1)58 def test_captured_pattern_days_later(self):59 input_text = '10 days later'60 parser = parsing.datetime_parsing(input_text)61 self.assertIn(input_text, parser[0])62 self.assertEqual(63 parser[0][1].strftime('%d-%m-%y'),64 parsing.date_from_duration(self.base_date, 10, 'days', 'later').strftime('%d-%m-%y')65 )66 self.assertEqual(len(parser), 1)67 def test_captured_pattern_year(self):68 input_text = '2010'69 parser = parsing.datetime_parsing(input_text)70 self.assertIn(input_text, parser[0])71 self.assertEqual(parser[0][1].strftime('%Y'), input_text)72 self.assertEqual(len(parser), 1)73 def test_captured_pattern_today(self):74 input_text = 'today'75 parser = parsing.datetime_parsing(input_text)76 self.assertIn(input_text, parser[0])77 self.assertEqual(parser[0][1].strftime('%d'), datetime.today().strftime('%d'))78 self.assertEqual(len(parser), 1)79 def test_captured_pattern_tomorrow(self):80 input_text = 'tomorrow'81 parser = parsing.datetime_parsing(input_text)82 self.assertIn(input_text, parser[0])83 self.assertEqual(84 parser[0][1].strftime('%d'),85 (datetime.today() + timedelta(days=1)).strftime('%d')86 )87 self.assertEqual(len(parser), 1)88 def test_captured_pattern_yesterday(self):89 input_text = 'yesterday'90 parser = parsing.datetime_parsing(input_text)91 self.assertIn(input_text, parser[0])92 self.assertEqual(93 parser[0][1].strftime('%d'),94 (datetime.today() - timedelta(days=1)).strftime('%d')95 )96 self.assertEqual(len(parser), 1)97 def test_captured_pattern_before_yesterday(self):98 input_text = 'day before yesterday'99 parser = parsing.datetime_parsing(input_text)100 self.assertIn(input_text, parser[0])101 self.assertEqual(102 parser[0][1].strftime('%d'),103 (datetime.today() - timedelta(days=2)).strftime('%d')104 )105 self.assertEqual(len(parser), 1)106 def test_captured_pattern_before_today(self):107 input_text = 'day before today'108 parser = parsing.datetime_parsing(input_text)109 self.assertIn(input_text, parser[0])110 self.assertEqual(111 parser[0][1].strftime('%d'),112 (datetime.today() - timedelta(days=1)).strftime('%d')113 )114 self.assertEqual(len(parser), 1)115 def test_captured_pattern_before_tomorrow(self):116 input_text = 'day before tomorrow'117 parser = parsing.datetime_parsing(input_text)118 self.assertIn(input_text, parser[0])119 self.assertEqual(120 parser[0][1].strftime('%d'),121 (datetime.today() - timedelta(days=0)).strftime('%d')122 )123 self.assertEqual(len(parser), 1)124 input_text = '2 days before'125 parser = parsing.datetime_parsing(input_text)126 self.assertIn(input_text, parser[0])127 self.assertEqual(128 parser[0][1].strftime('%d'),129 (datetime.today() - timedelta(days=2)).strftime('%d')130 )131 self.assertEqual(len(parser), 1)132 def test_captured_pattern_two_days(self):133 input_text = 'Monday and Friday'134 parser = parsing.datetime_parsing(input_text)135 self.assertIn('Monday', parser[0])136 self.assertIn('Friday', parser[1])137 self.assertEqual(138 parser[0][1].strftime('%d'),139 parsing.this_week_day(self.base_date, 0).strftime('%d')140 )141 self.assertEqual(142 parser[1][1].strftime('%d'),143 parsing.this_week_day(self.base_date, 4).strftime('%d')144 )145 self.assertEqual(len(parser), 2)146 def test_captured_pattern_first_quarter_of_year(self):147 input_text = 'First quarter of 2016'148 parser = parsing.datetime_parsing(input_text)149 self.assertIn(input_text, parser[0])150 self.assertEqual(parser[0][1][0].strftime('%d-%m-%Y'), '01-01-2016')151 self.assertEqual(parser[0][1][1].strftime('%d-%m-%Y'), '31-03-2016')152 self.assertEqual(len(parser), 1)153 def test_captured_pattern_last_quarter_of_year(self):154 input_text = 'Last quarter of 2015'155 parser = parsing.datetime_parsing(input_text)156 self.assertIn(input_text, parser[0])157 self.assertEqual(parser[0][1][0].strftime('%d-%m-%Y'), '01-09-2015')158 self.assertEqual(parser[0][1][1].strftime('%d-%m-%Y'), '31-12-2015')159 self.assertEqual(len(parser), 1)160 def test_captured_pattern_is_on_day(self):161 input_text = 'My birthday is on January 2nd.'162 parser = parsing.datetime_parsing(input_text)163 self.assertIn('January 2nd', parser[0])164 self.assertEqual(parser[0][1].month, 1)165 self.assertEqual(parser[0][1].day, 2)166 self.assertEqual(len(parser), 1)167 def test_captured_pattern_is_on_day_of_year_variation1(self):168 input_text = 'My birthday is on January 1st 2014.'169 parser = parsing.datetime_parsing(input_text)170 self.assertIn('January 1st 2014', parser[0])171 self.assertEqual(parser[0][1].strftime('%d-%m-%Y'), '01-01-2014')172 self.assertEqual(len(parser), 1)173 def test_captured_pattern_is_on_day_of_year_variation2(self):174 input_text = 'My birthday is on 2nd January 2014.'175 parser = parsing.datetime_parsing(input_text)176 self.assertIn('2nd January 2014', parser[0])177 self.assertEqual(parser[0][1].strftime('%d-%m-%Y'), '02-01-2014')178 self.assertEqual(len(parser), 1)179class DateTimeParsingTestCases(TestCase):180 """181 Unit tests for datetime parsing functions.182 """183 def test_next_week_day(self):184 base_date = datetime(2016, 12, 7, 10, 10, 52, 85280)185 weekday = 2 # Wednesday186 result = parsing.next_week_day(base_date, weekday)187 self.assertEqual(result, datetime(2016, 12, 14, 10, 10, 52, 85280))188 def test_previous_week_day(self):189 base_date = datetime(2016, 12, 14, 10, 10, 52, 85280)190 weekday = 2 # Wednesday191 result = parsing.previous_week_day(base_date, weekday)192 self.assertEqual(result, datetime(2016, 12, 7, 10, 10, 52, 85280))193 def test_this_week_day_before_day(self):194 base_date = datetime(2016, 12, 5, 10, 10, 52, 85280) # Monday195 weekday = 2 # Wednesday196 result = parsing.this_week_day(base_date, weekday)197 self.assertEqual(result, datetime(2016, 12, 7, 10, 10, 52, 85280))198 def test_this_week_day_after_day(self):199 base_date = datetime(2016, 12, 9, 10, 10, 52, 85280) # Friday200 weekday = 2 # Wednesday201 result = parsing.this_week_day(base_date, weekday)...

Full Screen

Full Screen

converter.py

Source:converter.py Github

copy

Full Screen

1# coding=utf-82__author__ = "Dragan Vidakovic"3def convert_to_latin(input_text):4 """5 Convert Serbian Cyrillic to Latin6 :param input_text: Cyrillic text7 :return: Latin text8 """9 # caps10 input_text = input_text.replace("А", "a")11 input_text = input_text.replace("Б", "b")12 input_text = input_text.replace("В", "v")13 input_text = input_text.replace("Г", "g")14 input_text = input_text.replace("Д", "d")15 input_text = input_text.replace("Ђ", "dj")16 input_text = input_text.replace("Е", "e")17 input_text = input_text.replace("Ж", "z")18 input_text = input_text.replace("З", "z")19 input_text = input_text.replace("И", "i")20 input_text = input_text.replace("Ј", "j")21 input_text = input_text.replace("К", "k")22 input_text = input_text.replace("Л", "l")23 input_text = input_text.replace("Љ", "lj")24 input_text = input_text.replace("М", "m")25 input_text = input_text.replace("Н", "n")26 input_text = input_text.replace("Њ", "nj")27 input_text = input_text.replace("О", "o")28 input_text = input_text.replace("П", "p")29 input_text = input_text.replace("Р", "r")30 input_text = input_text.replace("С", "s")31 input_text = input_text.replace("Т", "t")32 input_text = input_text.replace("Ћ", "c")33 input_text = input_text.replace("У", "u")34 input_text = input_text.replace("Ф", "f")35 input_text = input_text.replace("Х", "h")36 input_text = input_text.replace("Ц", "c")37 input_text = input_text.replace("Ч", "c")38 input_text = input_text.replace("Џ", "dz")39 input_text = input_text.replace("Ш", "s")40 # non caps41 input_text = input_text.replace("а", "a")42 input_text = input_text.replace("б", "b")43 input_text = input_text.replace("в", "v")44 input_text = input_text.replace("г", "g")45 input_text = input_text.replace("д", "d")46 input_text = input_text.replace("ђ", "dj")47 input_text = input_text.replace("е", "e")48 input_text = input_text.replace("ж", "z")49 input_text = input_text.replace("з", "z")50 input_text = input_text.replace("и", "i")51 input_text = input_text.replace("ј", "j")52 input_text = input_text.replace("к", "k")53 input_text = input_text.replace("л", "l")54 input_text = input_text.replace("љ", "lj")55 input_text = input_text.replace("м", "m")56 input_text = input_text.replace("н", "n")57 input_text = input_text.replace("њ", "nj")58 input_text = input_text.replace("о", "o")59 input_text = input_text.replace("п", "p")60 input_text = input_text.replace("р", "r")61 input_text = input_text.replace("с", "s")62 input_text = input_text.replace("т", "t")63 input_text = input_text.replace("ћ", "c")64 input_text = input_text.replace("у", "u")65 input_text = input_text.replace("ф", "f")66 input_text = input_text.replace("х", "h")67 input_text = input_text.replace("ц", "c")68 input_text = input_text.replace("ч", "c")69 input_text = input_text.replace("џ", "dz")70 input_text = input_text.replace("ш", "s")...

Full Screen

Full Screen

serbian_stemmer.py

Source:serbian_stemmer.py Github

copy

Full Screen

1# coding=utf-82__author__ = "Dragan Vidakovic"3import re4stop = {'biti', 'jesam', 'budem', 'sam', 'jesi', 'budes', 'si', 'jesmo', 'budemo', 'smo', 'jeste', 'budete', 'ste',5 'jesu', 'budu', 'su', 'bih', 'bejah', 'beh', 'bejase', 'bi', 'bese', 'bejasmo', 'bismo', 'besmo', 'bejaste',6 'biste', 'beste', 'bejahu', 'bejahu', 'bi', 'bise', 'behu', 'bio', 'bili', 'budimo', 'budite', 'bila', 'bilo',7 'bile', 'cu', 'ces', 'ce', 'cemo', 'cete', 'zelim', 'zelis', 'zeli', 'zelimo', 'zelite', 'zele', 'moram',8 'moras', 'mora', 'moramo', 'morate', 'moraju', 'trebam', 'trebas', 'treba', 'trebamo', 'trebate', 'trebaju',9 'mogu', 'mozes', 'moze', 'mozemo', 'mozete'}10def syllable_r(text):11 return re.sub(r'(^|[^aeiou])r($|[^aeiou])', r'\1R\2', text)12def has_vowel(text):13 if re.search(r'[aeiouR]', syllable_r(text)) is None:14 return False15 else:16 return True17def replace_special_characters(input_text):18 input_text = input_text.replace("Č", "C")19 input_text = input_text.replace("Ć", "C")20 input_text = input_text.replace("Dž", "Dz")21 input_text = input_text.replace("Đ", "Dj")22 input_text = input_text.replace("Š", "S")23 input_text = input_text.replace("Ž", "Z")24 input_text = input_text.replace("č", "c")25 input_text = input_text.replace("ć", "c")26 input_text = input_text.replace("dž", "dz")27 input_text = input_text.replace("đ", "dj")28 input_text = input_text.replace("š", "s")29 input_text = input_text.replace("ž", "z")30 return input_text31def transform(token, transformations):32 for search, swap in transformations:33 if token.endswith(search):34 return token[:-len(search)] + swap35 return token36def root(token, rules):37 for rule in rules:38 division = rule.match(token)39 if division is not None:40 if has_vowel(division.group(1)) and len(division.group(1)) > 1:41 return division.group(1)42 return token43def stem(input_text):44 input_text = replace_special_characters(input_text)45 output_text = ''46 rules = [re.compile(r'^('+osnova+')('+nastavak+r')$') for osnova, nastavak in [e.strip().split(' ') for e in open('rules.txt')]]47 transformations = [e.strip().split('\t') for e in open('transformations.txt')]48 for token in re.findall(r'\w+', input_text, re.UNICODE):49 if token.lower() in stop:50 output_text += token.lower() + ' '51 continue52 output_text += root(transform(token.lower(), transformations), rules) + ' '...

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 robotframework-pageobjects 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