Best Python code snippet using uiautomator
test_device_obj.py
Source: test_device_obj.py
...51 self.jsonrpc.objInfo.return_value = info52 self.assertEqual(self.obj.info,53 info)54 self.jsonrpc.objInfo.assert_called_once_with(self.obj.selector)55 def test_info_attr(self):56 info = {'contentDescription': '',57 'checked': False,58 'scrollable': False,59 'text': '',60 'packageName': 'android',61 'selected': False,62 'enabled': True,63 'bounds': {'top': 0,64 'left': 0,65 'right': 720,66 'bottom': 1184},67 'className':68 'android.widget.FrameLayout',69 'focusable': False,...
siswrap_tests.py
Source: siswrap_tests.py
...50 def test_creation(self):51 assert isinstance(self.report.conf_svc, ConfigurationService) is True52 assert isinstance(self.report.logger, Logger) is True53 # We should be able to access the ProcessInfo's attributes54 def test_info_attr(self):55 assert isinstance(self.report.info, ProcessInfo) is True56 assert self.report.info.runfolder == Helper.root + Helper.runfolder57 # And we should inherit from the base Wrapper class58 def test_inheritance(self):59 assert issubclass(ReportWrapper, Wrapper) is True60class TestWrapper(object):61 # Wrapper base class should be setup properly62 def test_creation(self, monkeypatch):63 def mocked_isdir(runpath):64 return True65 monkeypatch.setattr("os.path.isdir", mocked_isdir)66 wrapper = Wrapper(Helper.runfolder, Helper.conf, Helper.logger)67 assert isinstance(wrapper.info, ProcessInfo) is True68 assert isinstance(wrapper.conf_svc, ConfigurationService) is True69 assert isinstance(wrapper.logger, Logger) is True70 assert wrapper.QC_TYPE == "qc"71 assert wrapper.REPORT_TYPE == "report"72 # Run method should setup a ExecString for the calling object in question73 # and spawn a subprocess with it, as well as update the process info's74 # attributes.75 def test_run(self, monkeypatch):76 pass_mocked = True77 class MockedExecString(object):78 def __init__(self, wrapper, conf, runfolder):79 if pass_mocked:80 self.text = ["/bin/bash", "-c", "echo uggla"]81 else:82 self.text = ["/bin/uggla"]83 monkeypatch.setattr("siswrap.siswrap.ExecString", MockedExecString)84 w = Wrapper(Helper.runfolder, Helper.conf, Helper.logger)85 w.run()86 assert isinstance(w.info.proc, subprocess.Popen)87 assert w.info.state == "started"88 out, err = w.info.proc.communicate()89 assert out == "uggla\n"90 pass_mocked = False91 w.run()92 with pytest.raises(Exception) as err:93 out, err = w.info.proc.communicate()94 # Helper method should return the correct wrapper object for95 # different text inputs96 def test_new_wrapper(self):97 qc_wrap = Wrapper.new_wrapper("qc", Helper.runfolder,98 Helper.conf, Helper.logger)99 report_wrap = Wrapper.new_wrapper("report", Helper.runfolder,100 Helper.conf, Helper.logger)101 assert qc_wrap.type_txt == "qc"102 assert report_wrap.type_txt == "report"103 with pytest.raises(Exception) as err:104 Wrapper.new_wrapper("foo", Helper.runfolder,105 Helper.conf, Helper.logger)106 # Helper method should return the correct wrapper type in text107 # format for different URLs108 def test_url_to_type(self):109 test_urls = ["http://arteria1:1111/v1/api/qc/run/8312",110 "https://arteria12:3232/v2/api/report/run/3232",111 "http://testweb/api/1/qc/status",112 "http://testtest/api/v1/report/run"]113 test_types = ["qc", "report", "qc", "report"]114 for idx, url in enumerate(test_urls):115 assert Wrapper.url_to_type(url) == test_types[idx]116 with pytest.raises(Exception) as err:117 Wrapper.url_to_type("foo")118class TestQCWrapper(object):119 qc = QCWrapper(Helper.runfolder, Helper.conf, Helper.logger)120 # QCWrapper should be setup correctly121 def test_creation(self, monkeypatch):122 assert isinstance(self.qc.info, ProcessInfo) is True123 assert isinstance(self.qc.logger, Logger) is True124 assert isinstance(self.qc.conf_svc, ConfigurationService) is True125 # test the file copy126 dstdir = "/tmp/test_siswrap/runfolder_root/"127 testsrc = dstdir + "qc_file.txt"128 def mocked_get_setting(self, setting):129 if setting == "qc_file":130 return testsrc131 elif setting == "runfolder_root":132 return dstdir133 else:134 return setting135 # Create the src file136 import io137 if not os.path.isdir(dstdir + Helper.runfolder):138 os.makedirs(dstdir + Helper.runfolder)139 if not os.path.exists(testsrc):140 io.open(testsrc, 'a').close()141 monkeypatch.setattr("siswrap.siswrap.ConfigurationService.get_setting",142 mocked_get_setting)143 qc = QCWrapper(Helper.runfolder, Helper.conf, Helper.logger)144 assert os.path.exists(dstdir + Helper.runfolder +145 "/sisyphus_qc.xml") is True146 # remove the files147 import shutil148 shutil.rmtree(dstdir)149 # QCWrapper should be able to get the attributes from ProcessInfo150 def test_info_attr(self):151 assert isinstance(self.qc.info, ProcessInfo) is True152 assert self.qc.info.runfolder == Helper.root + Helper.runfolder153 # QCWrapper should inherit Wrapper154 def test_inheritance(self):155 assert issubclass(QCWrapper, Wrapper) is True156class TestExecString(object):157 # ExecString should be created with a text field containing the string158 # to be spawned in a subprocess later. String will be somewhat different159 # on which wrapper is calling. Settings read from the conf service.160 def test_creation(self, monkeypatch):161 class FooBar(object):162 def __init__(self):163 self.binary_conf_lookup = "foobar"164 def mocked_get_setting(self, setting):...
Check out the latest blogs from LambdaTest on this topic:
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.
Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.
“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.
With new-age project development methodologies like Agile and DevOps slowly replacing the old-age waterfall model, the demand for testing is increasing in the industry. Testers are now working together with the developers and automation testing is vastly replacing manual testing in many ways. If you are new to the domain of automation testing, the organization that just hired you, will expect you to be fast, think out of the box, and able to detect bugs or deliver solutions which no one thought of. But with just basic knowledge of testing, how can you be that successful test automation engineer who is different from their predecessors? What are the skills to become a successful automation tester in 2019? Let’s find out.
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!!