Best Python code snippet using robotframework-pageobjects_python
test.py
Source: test.py
1from tkinter import *2from tkinter.font import Font3import sdarobot4import threading5from tkinter import ttk6import time7import memory8import seasons_lengths9def _from_rgb(rgb):10 """translates an rgb tuple of int to a tkinter friendly color code11 """12 return "#%02x%02x%02x" % rgb13comp_bg = _from_rgb((255, 255, 255))14text_color = _from_rgb((255, 255, 255))15text_font = ('ariel', 12, 'bold')16comp_font = ('ariel', 14, 'bold')17adv_font = ('ariel', 10, 'bold')18adv_text_color = _from_rgb((240, 240, 240))19adv_color = _from_rgb((70, 70, 70))20background = _from_rgb((64, 64, 64))21buttons_color = _from_rgb((0, 117, 222))22window = Tk()23window.title("Welcome to Sdarobot")24window.geometry('400x500')25window.iconbitmap('icon.ico')26window['bg'] = background27header = Label(window, text="Welcome to Sdarobot!", bg=background, fg=buttons_color)28f = Font(header, comp_font)29f.configure(underline=True)30header.config(font=f)31url_label = Label(window, text="Series:", bg=background, fg=text_color)32url_label.config(font=text_font)33data_var = StringVar(window)34data_var.set("4 seasons")35data_label = Label(window, textvariable=data_var, bg=background, fg=text_color)36series_var = StringVar(window)37series = ttk.Combobox(window, textvariable=series_var, font=text_font, state='readonly')38# series.bind("<<ComboboxSelected>>", on_select)39# series['values'] = series_names40window.option_add('*TCombobox*Listbox.font', text_font)41season_label = Label(window, text="Season:", bg=background, fg=text_color)42season_label.config(font=text_font)43season_var = StringVar(window)44season = Spinbox(window, from_=1, to=20, width=2, bd=0, textvariable=season_var)45season.config(font=comp_font)46first_episode_label = Label(window, text="First episode:", bg=background, fg=text_color)47first_episode_label.config(font=text_font)48first_episode_var = StringVar(window)49first_episode = Spinbox(window, from_=1, to=100, width=2, bd=0, textvariable=first_episode_var)50first_episode.config(font=comp_font)51episodes_label = Label(window, text="Number of episodes:", bg=background, fg=text_color)52episodes_label.config(font=text_font)53episodes = Spinbox(window, from_=1, to=100, width=2, bd=0)54episodes.config(font=comp_font)55bar_style = ttk.Style(window)56bar_style.layout('text.Horizontal.TProgressbar',57 [('Horizontal.Progressbar.trough',58 {'children': [('Horizontal.Progressbar.pbar',59 {'side': 'left', 'sticky': 'ns'})],60 'sticky': 'nswe'}),61 ('Horizontal.Progressbar.label', {'sticky': ''})])62# set initial text63bar_style.configure('text.Horizontal.TProgressbar', text='0 %')64bar = ttk.Progressbar(window, orient=HORIZONTAL, length=300, mode='determinate', style='text.Horizontal.TProgressbar')65bar['value'] = 066state = 067start_photo = PhotoImage(file='start_button1.png', width=175, height=55)68start_on_hover_photo = PhotoImage(file='start_button_hover1.png', width=175, height=55)69start_disabled_photo = PhotoImage(file='start_button_disabled1.png', width=175, height=55)70start_label = Label(window, image=start_photo, bg=background)71# start_label.bind("<Enter>", on_hover_out_or_in)72# start_label.bind("<Leave>", on_hover_out_or_in)73# start_label.bind("<Button-1>", on_click)74advanced_text = StringVar(window)75advanced_text.set('Advanced >')76advanced_button = Button(window, textvariable=advanced_text, width=10,77 command=None, bg=adv_color, fg=text_color) # advanced_click78error_label = Label(window, text="An error has occurred. Wait just a few more seconds :)", bg=background, fg=text_color)79error_label.config(font=adv_font)80top_y = 7081pad_x = 1082header.place(x=95, y=10)83url_label.place(x=pad_x, y=top_y)84series.place(x=185, y=top_y)85data_label.place(x=185, y=top_y + 30)86season_label.place(x=pad_x, y=top_y + 60)87season.place(x=347, y=top_y + 60)88first_episode_label.place(x=pad_x, y=top_y + 120)89first_episode.place(x=347, y=top_y + 120)90episodes_label.place(x=pad_x, y=top_y + 180)91episodes.place(x=347, y=top_y + 180)92bar.place(x=50, y=top_y + 320)93error_label.place(x=27, y=top_y + 300)94start_label.place(x=112.5, y=top_y + 360)95advanced_button.place(x=312, y=top_y + 395)...
test_commands.py
Source: test_commands.py
1import unittest2from io import StringIO3from lxml import etree4from pyschematron.commands import validate5from pyschematron.commands import convert6from test_util import get_file7class TestValidateCommand(unittest.TestCase):8 def setUp(self):9 self.output_stream = StringIO()10 self.rcode = None11 def run_command(self, sch_file, xml_file, expected_result=0, output_type='text', verbosity=1):12 self.output_stream = StringIO()13 self.rcode = validate.main(sch_file, xml_file, output_stream=self.output_stream, output_type=output_type, verbosity=verbosity)14 self.assertEqual(expected_result, self.rcode)15 def test_validate(self):16 """Test whether the commands run, complete, and return the correct result code. We do not verify the actual output in this test"""17 self.run_command("data/schematron/all_elements.sch", "data/xml/diagnostics/more_than_three_animals.xml", -1)18 self.run_command("data/schematron/advanced_text.sch", "data/xml/basic1_ok.xml")19 self.run_command("data/schematron/diagnostics.sch", "data/xml/diagnostics/more_than_three_animals.xml", -1)20 def test_validate_to_svrl(self):21 self.run_command("data/schematron/all_elements.sch", "data/xml/diagnostics/more_than_three_animals.xml", output_type='svrl')22class TestConvertCommand(unittest.TestCase):23 def run_command(self, sch_file, expected_result=0, output_format='xslt'):24 self.output_stream = StringIO()25 self.rcode = convert.main(sch_file, output_stream=self.output_stream, output_format=output_format)26 self.assertEqual(expected_result, self.rcode)27 def test_convert(self):28 """Test whether the commands run, complete, and return the correct result code. We do not verify the actual output in this test"""29 self.run_command("data/schematron/advanced_text.sch")30 self.run_command("data/schematron/all_elements.sch")31 self.run_command("data/schematron/basic.sch")32 self.run_command("data/schematron/diagnostics.sch")33 self.run_command("data/schematron/full.sch")34 self.run_command("data/schematron/multilingual.sch")35 self.run_command("data/schematron/name_element.sch")36 self.run_command("data/schematron/schematron.sch")37 self.run_command("data/schematron/svrl.sch")38 def test_convert_to_minimal(self):39 self.run_command("data/schematron/advanced_text.sch", output_format='minimal')40 self.run_command("data/schematron/all_elements.sch", output_format='minimal')41 self.run_command("data/schematron/basic.sch", output_format='minimal')42 self.run_command("data/schematron/diagnostics.sch", output_format='minimal')43 self.run_command("data/schematron/full.sch", output_format='minimal')44 self.run_command("data/schematron/multilingual.sch", output_format='minimal')45 self.run_command("data/schematron/name_element.sch", output_format='minimal')46 self.run_command("data/schematron/schematron.sch", output_format='minimal')...
multiple_tests.pyde
Source: multiple_tests.pyde
...51def draw_text():52 textFont(f,8)53 textAlign(CENTER)54 text("Level 2", width/2, 7)55def advanced_text():56 noStroke();57 smooth();58 x = 159 background(100)60 message = "Level2"61 for i in range(len(message)):62 textSize(random.randint(6, 8))63 text(message[i], x, height - 1)64 x += textWidth(message[i]) + 165def draw():66 advanced_text()...
Check out the latest blogs from LambdaTest on this topic:
Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
In some sense, testing can be more difficult than coding, as validating the efficiency of the test cases (i.e., the ‘goodness’ of your tests) can be much harder than validating code correctness. In practice, the tests are just executed without any validation beyond the pass/fail verdict. On the contrary, the code is (hopefully) always validated by testing. By designing and executing the test cases the result is that some tests have passed, and some others have failed. Testers do not know much about how many bugs remain in the code, nor about their bug-revealing efficiency.
Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.
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!!