How to use _adb_screencap method in ATX

Best Python code snippet using ATX

device.py

Source: device.py Github

copy

Full Screen

...132 continue133 path, name = m.group(1), m.group(2)134 packages.append(self.Package(name, path))135 return packages136 def _adb_screencap(self, scale=1.0):137 """138 capture screen with adb shell screencap139 """140 remote_file = tempfile.mktemp(dir='/​data/​local/​tmp/​', prefix='screencap-', suffix='.png')141 local_file = tempfile.mktemp(prefix='atx-screencap-', suffix='.png')142 self.shell('screencap', '-p', remote_file)143 try:144 self.pull(remote_file, local_file)145 image = imutils.open_as_pillow(local_file)146 if scale is not None and scale != 1.0:147 image = image.resize([int(scale * s) for s in image.size], Image.BICUBIC)148 rotation = self.rotation()149 if rotation:150 method = getattr(Image, 'ROTATE_{}'.format(rotation*90))151 image = image.transpose(method)152 return image153 finally:154 self.remove(remote_file)155 os.unlink(local_file)156 def _adb_minicap(self, scale=1.0):157 """158 capture screen with minicap159 https:/​/​github.com/​openstf/​minicap160 """161 remote_file = tempfile.mktemp(dir='/​data/​local/​tmp/​', prefix='minicap-', suffix='.jpg')162 local_file = tempfile.mktemp(prefix='atx-minicap-', suffix='.jpg')163 (w, h, r) = self.display164 params = '{x}x{y}@{rx}x{ry}/​{r}'.format(x=w, y=h, rx=int(w*scale), ry=int(h*scale), r=r*90)165 try:166 self.shell('LD_LIBRARY_PATH=/​data/​local/​tmp', self.__minicap, '-s', '-P', params, '>', remote_file)167 self.pull(remote_file, local_file)168 image = imutils.open_as_pillow(local_file)169 return image170 finally:171 self.remove(remote_file)172 os.unlink(local_file)173 def screenshot(self, filename=None, scale=1.0, method=None):174 """175 Take device screenshot176 Args:177 - filename(string): optional, save int filename178 - scale(float): scale size179 - method(string): one of minicap,screencap180 Return:181 PIL.Image182 """183 image = None184 method = method or self._screenshot_method185 if method == 'minicap':186 try:187 image = self._adb_minicap(scale)188 except Exception as e:189 logger.warn("use minicap failed, fallback to screencap. error detail: %s", e)190 self._screenshot_method = 'screencap'191 return self.screenshot(filename=filename, scale=scale)192 elif method == 'screencap':193 image = self._adb_screencap(scale)194 else:195 raise RuntimeError("No such method(%s)" % method)196 if filename:197 image.save(filename)198 return image199 def click(self, x, y):200 '''201 same as adb -s ${SERIALNO} shell input tap x y202 FIXME(ssx): not tested on horizontal screen203 '''204 self.shell('input', 'tap', str(x), str(y))205 def forward(self, local_port, remote_port):206 '''207 adb port forward. return local_port...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Putting Together a Testing Team

As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.

QA Innovation – Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

What is Selenium Grid & Advantages of Selenium Grid

Manual cross browser testing is neither efficient nor scalable as it will take ages to test on all permutations & combinations of browsers, operating systems, and their versions. Like every developer, I have also gone through that ‘I can do it all phase’. But if you are stuck validating your code changes over hundreds of browsers and OS combinations then your release window is going to look even shorter than it already is. This is why automated browser testing can be pivotal for modern-day release cycles as it speeds up the entire process of cross browser compatibility.

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

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