How to use scroll_to method in Selene

Best Python code snippet using selene_python

test_esf_xqxq.py

Source: test_esf_xqxq.py Github

copy

Full Screen

...102 รงย‚ยนรฅย‡ยปรฅยŸยบรงยกย€รคยฟยกรฆยยฏ103 :return:104 """105 # รฉยกยตรฉยยขรฆยปยšรฅยŠยจรฅยˆยฐรฅยยŒรฅยŸยบรงยกย€รจยฏยฆรฆยƒย…106 self.page.scroll_to(595, 500)107 delay(1)108 e_base = self.page.element_is_exists('view[class="baseInfo"]')109 if e_base == True:110 self.page.get_element('view[class="baseInfo"]').tap()111 else:112 print("รฆยฒยกรฆยœย‰รฅยŸยบรงยกย€รคยฟยกรฆยยฏรฆยจยกรฅยย—")113 def test_goto_zbpt(self):114 """115 รงย‚ยนรฅย‡ยปรฅย‘ยจรจยพยนรฉย…ยรฅยฅย—116 :return:117 """118 self.page.scroll_to(750, 500)119 delay(1)120 e_map = self.page.element_is_exists('view[class="pr map"][data-type="0"]')121 if e_map == True:122 self.page.get_element('view[class="pr map"][data-type="0"]').tap()123 else:124 print("รฆยฒยกรฆยœย‰รฅย‘ยจรจยพยนรฉย…ยรฅยฅย—รฆยจยกรฅยย—")125 def test_goto_xqhx(self):126 """127 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹128 :return:129 """130 self.page.scroll_to(980, 500)131 delay(1)132 houseTypes = self.page.element_is_exists('view[class="houseTypes"]')133 if houseTypes == True:134 self.page.get_element('view[class="houseTypes"]').tap()135 else:136 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹รฆยจยกรฅยย—")137 def test_goto_xqhximg(self):138 """139 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹รฅย›ยพรงย‰ย‡140 :return:141 """142 self.page.scroll_to(900, 500)143 delay(1)144 house_img = self.page.element_is_exists('view[class="typeImg"]')145 if house_img == True:146 #img = self.page.get_element('/โ€‹/โ€‹view/โ€‹view[7]/โ€‹scroll-view/โ€‹view/โ€‹view')147 imgs = self.page.get_elements('view[class="typeImg"]')148 imgs[0].tap()149 else:150 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹รฆยจยกรฅยย—")151 def test_goto_xqhxmsg(self):152 """153 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹-รฅย’ยจรจยฏยขรฅยœยจรฅย”ยฎ154 :return:155 """156 self.page.scroll_to(900, 500)157 delay(1)158 house_msg = self.page.element_is_exists('view[class="typeMsg"]')159 if house_msg == True:160 msg = self.page.get_element('/โ€‹/โ€‹view[@class="typeMsg"]/โ€‹view[@class="msg"]')161 msg.tap()162 else:163 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรฆยˆยทรฅยžย‹รฆยจยกรฅยย—")164 def test_goto_housecomment(self):165 """166 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรจยฏย„รจยฎยบ-รฅย…ยจรฉยƒยจรจยฏย„รจยฎยบ167 :return:168 """169 self.page.scroll_to(1180, 500)170 delay(1)171 house_com = self.page.element_is_exists('text', inner_text="รฅย…ยจรฉยƒยจรจยฏย„รจยฎยบ")172 if house_com == True:173 comment = self.page.get_element('text', inner_text="รฅย…ยจรฉยƒยจรจยฏย„รจยฎยบ")174 comment.tap()175 else:176 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรจยฏย„รจยฎยบรฆยจยกรฅยย—")177 def test_goto_comxq(self):178 """179 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรจยฏย„รจยฎยบ-รฅย…ยจรฉยƒยจรจยฏย„รจยฎยบ180 :return:181 """182 self.page.scroll_to(1350, 500)183 delay(1)184 comxq = self.page.element_is_exists('view[class="commentItem"]')185 if comxq == True:186 xq = self.page.get_elements('view[class="commentItem"]')187 xq[0].tap()188 else:189 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรจยฏย„รจยฎยบรฆยจยกรฅยย—")190 def test_goto_plimg(self):191 """192 รงย‚ยนรฅย‡ยปรจยฏย„รจยฎยบรฅย›ยพรงย‰ย‡193 :return:194 """195 self.page.scroll_to(1400, 500)196 delay(1)197 plcom = self.page.element_is_exists('view[class="commentItem"]')198 if plcom == True:199 plimg = self.page.get_elements('/โ€‹/โ€‹view[@class="commentItem"][1]/โ€‹/โ€‹view[@class="flex pr commentImages"]/โ€‹view')200 if len(plimg) > 0:201 plimg[0].tap()202 else:203 print("รฆยฒยกรฆยœย‰รจยฏย„รจยฎยบรฅย›ยพรงย‰ย‡")204 else:205 print("รฆยฒยกรฆยœย‰รจยฏย„รจยฎยบ")206 def test_goto_pldz(self):207 """208 รจยฏย„รจยฎยบรงย‚ยนรจยตยž209 :return:210 """211 self.page.scroll_to(1400, 500)212 delay(1)213 pldz = self.page.element_is_exists('view[class="center"][data-index="0"][data-level="1"]')214 if pldz == True:215 dz = self.page.get_elements('view[class="center"][data-index="0"][data-level="1"]')216 dz[0].tap()217 else:218 print("รฆยฒยกรฆยœย‰รจยฏย„รจยฎยบ")219 def test_goto_qxdz(self):220 """221 รฅยย–รฆยถยˆรงย‚ยนรจยตยž222 :return:223 """224 self.page.scroll_to(1400, 500)225 delay(1)226 #รฆยœย‰รงย‚ยนรฉย—ยฎรฉยขย˜227 qxdz = self.page.element_is_exists('view[class="center like"][data-index="0"][data-level="1"]')228 if qxdz == True:229 qx = self.page.get_elements('view[class="center like"][data-index="0"][data-level="1"]')230 qx[0].tap()231 else:232 print("รฆยฒยกรฆยœย‰รงย‚ยนรจยตยž")233 def test_goto_wypl(self):234 """235 รงย‚ยนรฅย‡ยปรฆยˆย‘รจยฆยรจยฏย„รจยฎยบ236 :return:237 """238 self.page.scroll_to(1400, 500)239 delay(1)240 e = self.page.get_element('view[class="center iWant"]')241 e.tap()242 def test_goto_xqzj(self):243 """244 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรคยธย“รฅยฎยถ245 :return:246 """247 self.page.scroll_to(1490, 500)248 delay(1)249 elms = self.page.get_elements('view[class="between expert"]')250 if len(elms) > 0:251 elms[0].tap()252 else:253 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรคยธย“รฅยฎยถ")254 def test_goto_zjim(self):255 """256 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรคยธย“รฅยฎยถim257 :return:258 """259 self.page.scroll_to(1490, 500)260 delay(1)261 elms = self.page.get_elements('view[class="msg"]')262 if len(elms) > 0:263 elms[0].tap()264 else:265 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรคยธย“รฅยฎยถ")266 def test_goto_zjtel(self):267 """268 รงย‚ยนรฅย‡ยปรฅยฐยรฅยŒยบรคยธย“รฅยฎยถtel269 :return:270 """271 self.page.scroll_to(1490, 500)272 delay(1)273 elms = self.page.get_elements('view[class="tel"]')274 if len(elms) > 0:275 elms[0].tap()276 else:277 print("รฆยฒยกรฆยœย‰รฅยฐยรฅยŒยบรคยธย“รฅยฎยถ")278 def test_goto_housetab(self):279 """280 รฅยœยจรฅย”ยฎรฆยˆยฟรฆยบยรฅย’ยŒรฅยœยจรงยงยŸรฆยˆยฟรฆยบยtabรฅยˆย‡รฆยยข281 :return:282 """283 self.page.scroll_to(1700, 500)284 delay(1)285 e = self.page.get_element('view[class="pr typeI"][data-type="2"]')286 e.tap()287 delay(2)288 e = self.page.get_element('view[class="pr typeI"][data-type="1"]')289 e.tap()290 def test_goto_selltab(self):291 """292 รฅยœยจรฅย”ยฎรฆยˆยฟรฆยบยtab293 :return:294 """295 self.page.scroll_to(1700, 500)296 delay(1)297 selltab = self.page.element_is_exists('view[class="pr typeI active"][data-type="1"]')298 if selltab == True:299 # รฅย…ยˆรจยŽยทรฅยย–รฆย‰ย€รฆยœย‰item300 elm_items = self.page.get_elements('view[class="item"]')301 print(len(elm_items))302 # รงยฌยฌรคยธย€รคยธยชitem303 elm_first_item = elm_items[0]304 # รงย‚ยนรฅย‡ยป305 elms = elm_first_item.get_element('sell_item').get_elements('view')306 elms[0].tap()307 else:308 print(0)309 def test_goto_renttab(self):310 """311 รฅยœยจรงยงยŸรฆยˆยฟรฆยบยtab312 :return:313 """314 self.page.scroll_to(1700, 500)315 delay(1)316 e = self.page.get_element('view[class="pr typeI"][data-type="2"]')317 e.tap()318 delay(2)319 renttab = self.page.element_is_exists('view[class="pr typeI active"][data-type="2"]')320 if renttab == True:321 # รฅย…ยˆรจยŽยทรฅยย–รฆย‰ย€รฆยœย‰item322 elm_items = self.page.get_elements('view[class="item"]')323 # รงยฌยฌรคยธย€รคยธยชitem324 elm_first_item = elm_items[0]325 # รงย‚ยนรฅย‡ยป326 elms = elm_first_item.get_element('rent_item').get_elements('view')327 elms[0].tap()328 else:329 print(0)330 def test_goto_zbxq(self):331 """332 รฅย‘ยจรจยพยนรฅยฐยรฅยŒยบ333 :return:334 """335 self.page.scroll_to(2000, 500)336 delay(1)337 view_zbxq = self.page.element_is_exists('view[class="villageList"]')338 if view_zbxq == True:339 # รฅย…ยˆรจยŽยทรฅยย–รฆย‰ย€รฆยœย‰item340 elm_items = self.page.get_elements('/โ€‹/โ€‹view[@class="villageList"]/โ€‹view[@class="item"]')341 print(len(elm_items))342 # รงยฌยฌรคยธย€รคยธยชitem343 elm_first_item = elm_items[0]344 # รงย‚ยนรฅย‡ยป345 elms = elm_first_item.get_element('villageitem').get_elements('view')346 print(len(elms))347 elms[0].tap()348 else:349 print("รฆยฒยกรฆยœย‰รฅย‘ยจรจยพยนรฅยฐยรฅยŒยบ")...

Full Screen

Full Screen

test_date_field.py

Source: test_date_field.py Github

copy

Full Screen

...15 menu3 = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†' #รคยธยปรฉยกยตรฆย‰ย“รฅยผย€รจยยœรฅยย•รฆย—ยถรคยฝยฟรงย”ยจ16 17 def test_case_imited(self):18 '''รฉย™ยรฅยˆยถ_รฅยˆยทรฆย–ยฐ_รฉย‡ยรจยฎยกรงยฎย—'''19# self.scroll_to('460')20 #time.sleep(0.5)21 state_date = 'รฅยผย€รฅยงย‹รฆย—ยฅรฆยœยŸ'22 comp = DateFieldPage(self.driver, state_date)23 #รงย‚ยนรฅย‡ยปรฆย—ยฅรฆยœยŸรงยกยฎรจยฎยครฆยŒย‰รฉย’ยฎ 24 today = datetime.today().strftime('%Y-%m-%d')25 yesterday =(datetime.today() + timedelta(-1)).strftime('%Y-%m-%d')26 27 28 start_time = comp.get_now_date(today) 29 self.assertEqual(today, start_time, msg=state_date + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')30 end_date = 'รงยปย“รฆยยŸรฆย—ยฅรฆยœยŸ'31 comp = DateFieldPage(self.driver, end_date)32 #รงยปย“รฆยยŸรฆย—ยถรฉย—ยดรฅยยชรจยƒยฝรฉย€ย‰รฆย‹ยฉรฅยผย€รฅยงย‹รฆย—ยถรฉย—ยดรคยนย‹รฅยยŽรฆย˜ยฏรฆย•ยฐรฆยยฎรฏยผยŒรฆย‰ย€รคยปยฅรฅยผย€รฅยงย‹รฆย—ยถรฉย—ยดรคยนย‹รฅย‰ยรงยšย„รฆย—ยถรฉย—ยดรคยธยบday disabledรฏยผยŒรฅยผย€รฅยงย‹รคยนย‹รฅยยŽรฆย˜ยฏday active33 todayStatus = comp.get_end_date_status(end_date,today)34 self.assertIn("day active", todayStatus, msg=end_date + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡') 35 yesterdayStatus = comp.get_end_date_status(end_date,yesterday) 36 self.assertIn("day disabled", yesterdayStatus, msg=end_date + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')37 38 def test_type_case(self):39 '''รงยฑยปรฅยžย‹'''40# self.scroll_to('0')41 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฅยยรงยงยฐ'42 comp = DateFieldPage(self.driver, name)43 self.assertEqual('text', comp.get_attr('type'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')44 self.assertEqual('form-control Wdate', comp.get_attr('class'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')45 self.assertEqual('DateField', comp.get_attr('fieldtype'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')46 47 def test_readonly_case(self):48 '''รฆย˜ยพรงยคยบรฅยยชรจยฏยปรฅย’ยŒรฆยยกรคยปยถรฅยยชรจยฏยป'''49# self.scroll_to('0')50 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆย˜ยพรงยคยบรฅยยชรจยฏยป'51 comp = DateFieldPage(self.driver, name)52 self.assertTrue(comp.readonly_test(), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')53 54# self.scroll_to('800')55 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฅยยชรจยฏยปรฆยยกรคยปยถ'56 comp = DateFieldPage(self.driver, name)57 self.assertTrue(comp.readonly_test(), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')58 59 def test_hide_case(self):60 '''รฆย˜ยพรงยคยบรฉยšยรจย—ยรฅย’ยŒรฆยยกรคยปยถรฉยšยรจย—ย'''61# self.scroll_to('0')62 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆย˜ยพรงยคยบรฉยšยรจย—ย'63 comp = DateFieldPage(self.driver, name)64 self.assertEqual('hidden', comp.get_attr('type'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')65 66 67 68 def test_only_value_case(self):69 '''รฅยยชรจยฏยปรฆย—ยถรคยปย…รฆย˜ยพรงยคยบรฅย€ยผ'''70 self.scroll_to('0')71 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฅยยชรจยฏยปรฆย—ยถรคยปย…รฆย˜ยพรงยคยบรฅย€ยผ'72 comp = DateFieldPage(self.driver, name)73 self.assertTrue(comp.only_value(), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')74 75 def test_desription_case(self):76 '''รฆยยรจยฟยฐ'''77 self.scroll_to('550')78 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆยยรจยฟยฐ'79 comp = DateFieldPage(self.driver, name)80 self.assertEqual('รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆยยรจยฟยฐ', comp.get_attr('discript'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')81 82 def test_value_case(self):83 '''รฅย€ยผ'''84 self.scroll_to('550')85 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฅย€ยผรจย„ยšรฆยœยฌ'86 comp = DateFieldPage(self.driver, name)87 self.assertEqual(datetime.today().strftime('%Y-%m-%d'), comp.get_attr('value'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')88 89 90 def test_not_null_case(self):91 '''รฉยยžรงยฉยบรฆ ยกรฉยชยŒ'''92 self.scroll_to('550')93 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฉยยžรงยฉยบรฆ ยกรฉยชยŒ'94 comp = DateFieldPage(self.driver, name)95 self.assertIn("'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฉยยžรงยฉยบรฆ ยกรฉยชยŒ'รฅยฟย…รฉยกยปรฅยกยซรฅย†ย™", comp.set_val_save_get_msg(''), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')96 97 def test_show_when_hide_case(self):98 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฉยšยรจย—ยรฆย—ยถรฆย˜ยพรงยคยบรฅย€ยผ'99 comp = DateFieldPage(self.driver, name)100 comp.from_scroll_to('600')101 self.assertEqual('hidden', comp.get_attr('type'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')102 self.assertIn("รฆยŽยงรคยปยถรฅยทยฒรฉยšยรจย—ย",comp.get_curpage_span(), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')103 104 def test_format_case(self):105 '''รฆย˜ยพรงยคยบรฅยยชรจยฏยปรฅย’ยŒรฆยยกรคยปยถรฅยยชรจยฏยป'''106 self.scroll_to('0')107 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆ ยผรฅยผยรฅยนยด'108 comp = DateFieldPage(self.driver, name)109 self.assertEqual('yyyy',comp.get_attr('datefmt'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')110 111 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆ ยผรฅยผยรฅยนยดรฆยœยˆ'112 comp = DateFieldPage(self.driver, name)113 self.assertEqual('yyyy-MM-dd',comp.get_attr('datefmt'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡') 114 115 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆ ยผรฅยผยรฅยนยดรฅยˆยฐรงยงย’'116 comp = DateFieldPage(self.driver, name)117 self.assertEqual('yyyy-MM-dd HH:mm:ss',comp.get_attr('datefmt'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡') 118 119 name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆ ยผรฅยผยรฆย—ยถรฅยˆย†รงยงย’'120 comp = DateFieldPage(self.driver, name)121 self.assertEqual('HH:mm:ss',comp.get_attr('datefmt'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡') 122 #def test_print_hide_case(self):123 # '''รฆย‰ย“รฅยยฐรฆย—ยถรฉยšยรจย—ยรฆยยกรคยปยถ'''124 # self.scroll_to('1000')125 # name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆย‰ย“รฅยยฐรฆย—ยถรฉยšยรจย—ยรฆยยกรคยปยถ'126 # comp = DateFieldPage(self.driver, name)127 # self.assertIsNone(comp.find_element_by_css_selector('input[name="'+name+'"]'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')128 # 129 # def test_show_when_print_case(self):130 # '''รฆย‰ย“รฅยยฐรฉยšยรจย—ยรฆย—ยถรฆย˜ยพรงยคยบรฅย€ยผ'''131 # self.scroll_to('1000')132 # name = 'รฆย—ยฅรฆยœยŸรฉย€ย‰รฆย‹ยฉรฆยกย†_รฆย‰ย“รฅยยฐรฉยšยรจย—ยรฆย—ยถรฆย˜ยพรงยคยบรฅย€ยผ'133 # comp = DateFieldPage(self.driver, name)134 # self.assertEqual("รฆย‰ย“รฅยยฐรฉยšยรจย—ยรฆย—ยถรฆย˜ยพรงยคยบรฅย€ยผ", comp.get_text_by_css_selector('#toAll p'), msg=name + 'รฆยฃย€รฉยชยŒรคยธยรฉย€ยšรจยฟย‡')135 136 137 138 def init(self):139 self.test_case_imited()140 '''รงยฑยปรฅยžย‹รฃย€ยรฅยยชรจยฏยปรฃย€ยรฉยšยรจย—ยรฅยฑยžรฆย€ยงรฆยตย‹รจยฏย•'''141 self.test_type_case()142 self.test_readonly_case() 143 self.test_hide_case()144 self.test_only_value_case()145 self.test_desription_case()...

Full Screen

Full Screen

document_structure_page.py

Source: document_structure_page.py Github

copy

Full Screen

1#!/โ€‹usr/โ€‹bin/โ€‹env python32# coding: utf-83# Copyright (C) 2017, 2018 Robert Griesel4# This program is free software: you can redistribute it and/โ€‹or modify5# it under the terms of the GNU General Public License as published by6# the Free Software Foundation, either version 3 of the License, or7# (at your option) any later version.8# 9# This program is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12# GNU General Public License for more details.13# 14# You should have received a copy of the GNU General Public License15# along with this program. If not, see <http:/โ€‹/โ€‹www.gnu.org/โ€‹licenses/โ€‹>16import gi17gi.require_version('Gtk', '3.0')18from gi.repository import Gtk19from gi.repository import GObject20import time21class DocumentStructurePage(Gtk.Overlay):22 def __init__(self):23 Gtk.Overlay.__init__(self)24 self.labels = dict()25 self.vbox = Gtk.VBox()26 self.content_vbox = Gtk.VBox()27 self.scroll_to = None28 self.add_buttons()29 self.add_scrolled_window()30 self.show_all()31 self.vbox.connect('size-allocate', self.on_scroll_or_resize)32 self.scrolled_window.get_vadjustment().connect('value-changed', self.on_scroll_or_resize)33 self.vbox.connect('realize', self.on_scroll_or_resize)34 self.next_button.connect('clicked', self.on_next_button_clicked)35 self.prev_button.connect('clicked', self.on_prev_button_clicked)36 def add_content_widget(self, name, widget):37 self.content_vbox.pack_start(widget, False, False, 0)38 def add_label(self, name, text):39 label_inline = Gtk.Label(text)40 label_inline.set_xalign(0)41 label_inline.get_style_context().add_class('headline')42 self.content_vbox.pack_start(label_inline, False, False, 0)43 label_overlay = Gtk.Label(text)44 label_overlay.set_xalign(0)45 label_overlay.set_halign(Gtk.Align.START)46 label_overlay.set_valign(Gtk.Align.START)47 label_overlay.set_size_request(148, -1)48 label_overlay.get_style_context().add_class('overlay')49 self.add_overlay(label_overlay)50 self.set_overlay_pass_through(label_overlay, True)51 self.labels[name] = {'inline': label_inline, 'overlay': label_overlay}52 def add_buttons(self):53 self.tabs_box = Gtk.HBox()54 self.tabs_box.get_style_context().add_class('tabs-box')55 self.tabs_box.pack_start(Gtk.Label('Files'), False, False, 0)56 self.vbox.pack_start(self.tabs_box, False, False, 0)57 self.tabs = Gtk.Toolbar()58 self.tabs.set_style(Gtk.ToolbarStyle.ICONS)59 self.tabs.set_orientation(Gtk.Orientation.HORIZONTAL)60 self.tabs.set_icon_size(Gtk.IconSize.SMALL_TOOLBAR)61 self.tabs_box.pack_end(self.tabs, False, False, 0)62 self.prev_button = Gtk.ToolButton()63 self.prev_button.set_icon_name('go-up-symbolic')64 self.prev_button.set_focus_on_click(False)65 self.prev_button.set_tooltip_text(_('Back'))66 self.tabs.insert(self.prev_button, -1)67 self.next_button = Gtk.ToolButton()68 self.next_button.set_icon_name('go-down-symbolic')69 self.next_button.set_focus_on_click(False)70 self.next_button.set_tooltip_text(_('Forward'))71 self.tabs.insert(self.next_button, -1)72 def add_scrolled_window(self):73 self.scrolled_window = Gtk.ScrolledWindow()74 self.scrolled_window.add(self.content_vbox)75 self.vbox.pack_start(self.scrolled_window, True, True, 0)76 self.add(self.vbox)77 def on_scroll_or_resize(self, *args):78 label_offsets = self.get_label_offsets()79 scrolling_offset = self.scrolled_window.get_vadjustment().get_value()80 self.prev_button.set_sensitive(scrolling_offset != 0)81 self.next_button.set_sensitive(scrolling_offset < label_offsets[-1] and scrolling_offset < self.content_vbox.get_allocated_height() - self.scrolled_window.get_allocated_height())82 self.update_labels()83 def update_labels(self):84 tabs_height = self.tabs_box.get_allocated_height()85 scrolling_offset = self.scrolled_window.get_vadjustment().get_value()86 self.tabs_box.get_style_context().remove_class('no-border')87 for label_name, label_offset in zip(self.labels, self.get_label_offsets()):88 margin_top = max(0, label_offset - int(scrolling_offset))89 self.labels[label_name]['overlay'].set_margin_top(margin_top)90 if margin_top > 0 and margin_top <= tabs_height:91 self.tabs_box.get_style_context().add_class('no-border')92 def on_next_button_clicked(self, button):93 scrolling_offset = self.scrolled_window.get_vadjustment().get_value()94 for label_offset in self.get_label_offsets():95 if scrolling_offset < label_offset:96 self.scroll_view(label_offset)97 break98 def on_prev_button_clicked(self, button):99 scrolling_offset = self.scrolled_window.get_vadjustment().get_value()100 for label_offset in reversed([0] + self.get_label_offsets()):101 if scrolling_offset > label_offset:102 self.scroll_view(label_offset)103 break104 def get_label_offsets(self):105 offsets = list()106 offset = self.tabs_box.get_allocated_height()107 labels = [label['inline'] for label in self.labels.values()]108 for child in self.content_vbox.get_children():109 if child in labels:110 offsets.append(offset)111 if child.is_visible():112 offset += child.get_allocated_height()113 return offsets114 def scroll_view(self, position, duration=0.2):115 adjustment = self.scrolled_window.get_vadjustment()116 self.scroll_to = {'position_start': adjustment.get_value(), 'position_end': position, 'time_start': time.time(), 'duration': duration}117 self.scrolled_window.set_kinetic_scrolling(False)118 GObject.timeout_add(15, self.do_scroll)119 def do_scroll(self):120 if self.scroll_to != None:121 adjustment = self.scrolled_window.get_vadjustment()122 time_elapsed = time.time() - self.scroll_to['time_start']123 if self.scroll_to['duration'] == 0:124 time_elapsed_percent = 1125 else:126 time_elapsed_percent = time_elapsed /โ€‹ self.scroll_to['duration']127 if time_elapsed_percent >= 1:128 adjustment.set_value(self.scroll_to['position_end'])129 self.scroll_to = None130 self.scrolled_window.set_kinetic_scrolling(True)131 return False132 else:133 adjustment.set_value(self.scroll_to['position_start'] * (1 - self.ease(time_elapsed_percent)) + self.scroll_to['position_end'] * self.ease(time_elapsed_percent))134 return True135 return False...

Full Screen

Full Screen

config_data.py

Source: config_data.py Github

copy

Full Screen

1#!/โ€‹usr/โ€‹bin/โ€‹env python32# vim:fileencoding=utf-83# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>4# Utils {{{5from gettext import gettext as _6from functools import partial7from kitty.conf.definition import option_func8from kitty.conf.utils import (9 positive_int, python_string, to_color10)11# }}}12all_options = {}13o, k, g, all_groups = option_func(all_options, {14 'colors': [_('Colors')],15 'diff': [_('Diffing'), ],16 'shortcuts': [_('Keyboard shortcuts')],17})18g('diff')19def syntax_aliases(raw):20 ans = {}21 for x in raw.split():22 a, b = x.partition(':')[::2]23 if a and b:24 ans[a.lower()] = b25 return ans26o('syntax_aliases', 'pyj:py recipe:py', option_type=syntax_aliases, long_text=_('''27File extension aliases for syntax highlight28For example, to syntax highlight :file:`file.xyz` as29:file:`file.abc` use a setting of :code:`xyz:abc`30'''))31o('num_context_lines', 3, option_type=positive_int, long_text=_('''32The number of lines of context to show around each change.'''))33o('diff_cmd', 'auto', long_text=_('''34The diff command to use. Must contain the placeholder :code:`_CONTEXT_`35which will be replaced by the number of lines of context. The default36is to search the system for either git or diff and use that, if found.37'''))38o('replace_tab_by', r'\x20\x20\x20\x20', option_type=python_string, long_text=_('''39The string to replace tabs with. Default is to use four spaces.'''))40g('colors')41o('pygments_style', 'default', long_text=_('''42The pygments color scheme to use for syntax highlighting.43See :link:`pygments colors schemes <https:/โ€‹/โ€‹help.farbox.com/โ€‹pygments.html>` for a list of schemes.'''))44c = partial(o, option_type=to_color)45c('foreground', 'black', long_text=_('Basic colors'))46c('background', 'white')47c('title_fg', 'black', long_text=_('Title colors'))48c('title_bg', 'white')49c('margin_bg', '#fafbfc', long_text=_('Margin colors'))50c('margin_fg', '#aaaaaa')51c('removed_bg', '#ffeef0', long_text=_('Removed text backgrounds'))52c('highlight_removed_bg', '#fdb8c0')53c('removed_margin_bg', '#ffdce0')54c('added_bg', '#e6ffed', long_text=_('Added text backgrounds'))55c('highlight_added_bg', '#acf2bd')56c('added_margin_bg', '#cdffd8')57c('filler_bg', '#fafbfc', long_text=_('Filler (empty) line background'))58c('hunk_margin_bg', '#dbedff', long_text=_('Hunk header colors'))59c('hunk_bg', '#f1f8ff')60c('search_bg', '#444', long_text=_('Highlighting'))61c('search_fg', 'white')62c('select_bg', '#b4d5fe')63c('select_fg', 'black')64g('shortcuts')65k('quit', 'q', 'quit', _('Quit'))66k('quit', 'esc', 'quit', _('Quit'))67k('scroll_down', 'j', 'scroll_by 1', _('Scroll down'))68k('scroll_down', 'down', 'scroll_by 1', _('Scroll down'))69k('scroll_up', 'k', 'scroll_by -1', _('Scroll up'))70k('scroll_up', 'up', 'scroll_by -1', _('Scroll up'))71k('scroll_top', 'home', 'scroll_to start', _('Scroll to top'))72k('scroll_bottom', 'end', 'scroll_to end', _('Scroll to bottom'))73k('scroll_page_down', 'page_down', 'scroll_to next-page', _('Scroll to next page'))74k('scroll_page_down', 'space', 'scroll_to next-page', _('Scroll to next page'))75k('scroll_page_up', 'page_up', 'scroll_to prev-page', _('Scroll to previous page'))76k('next_change', 'n', 'scroll_to next-change', _('Scroll to next change'))77k('prev_change', 'p', 'scroll_to prev-change', _('Scroll to previous change'))78k('all_context', 'a', 'change_context all', _('Show all context'))79k('default_context', '=', 'change_context default', _('Show default context'))80k('increase_context', '+', 'change_context 5', _('Increase context'))81k('decrease_context', '-', 'change_context -5', _('Decrease context'))82k('search_forward', '/โ€‹', 'start_search regex forward', _('Search forward'))83k('search_backward', '?', 'start_search regex backward', _('Search backward'))84k('next_match', '.', 'scroll_to next-match', _('Scroll to next search match'))85k('prev_match', ',', 'scroll_to prev-match', _('Scroll to previous search match'))86k('next_match', '>', 'scroll_to next-match', _('Scroll to next search match'))87k('prev_match', '<', 'scroll_to prev-match', _('Scroll to previous search match'))88k('search_forward_simple', 'f', 'start_search substring forward', _('Search forward (no regex)'))89k('search_backward_simple', 'b', 'start_search substring backward', _('Search backward (no regex)'))...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Migrating Test Automation Suite To Cypress 10

There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Testing Modern Applications With Playwright ????

Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.

Test Optimization for Continuous Integration

โ€œTest frequently and early.โ€ If youโ€™ve been following my testing agenda, youโ€™re probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. Iโ€™ve encountered several teams who have a lot of automated tests but donโ€™t use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.

Unveiling Samsung Galaxy Z Fold4 For Mobile App Testing

Hey LambdaTesters! Weโ€™ve got something special for you this week. ????

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 Selene 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