Best Python code snippet using pyatom_python
value.py
Source:value.py  
...17import time18from utils import Utils19from server_exception import LdtpServerException20class Value(Utils):21   def verifyscrollbarvertical(self, window_name, object_name):22      """23      Verify scrollbar is vertical24      25      @param window_name: Window name to type in, either full name,26      LDTP's name convention, or a Unix glob.27      @type window_name: string28      @param object_name: Object name to type in, either full name,29      LDTP's name convention, or a Unix glob.30      @type object_name: string31      32      @return: 1 on success.33      @rtype: integer34      """35      try:36         object_handle = self._get_object_handle(window_name, object_name)37         if object_handle.AXOrientation == "AXVerticalOrientation":38            return 139      except:40         pass41      return 042   def verifyscrollbarhorizontal(self, window_name, object_name):43      """44      Verify scrollbar is horizontal45      46      @param window_name: Window name to type in, either full name,47      LDTP's name convention, or a Unix glob.48      @type window_name: string49      @param object_name: Object name to type in, either full name,50      LDTP's name convention, or a Unix glob.51      @type object_name: string52      53      @return: 1 on success.54      @rtype: integer55      """56      try:57         object_handle = self._get_object_handle(window_name, object_name)58         if object_handle.AXOrientation == "AXHorizontalOrientation":59            return 160      except:61         pass62      return 063   def setmax(self, window_name, object_name):64      """65      Set max value66      67      @param window_name: Window name to type in, either full name,68      LDTP's name convention, or a Unix glob.69      @type window_name: string70      @param object_name: Object name to type in, either full name,71      LDTP's name convention, or a Unix glob.72      @type object_name: string73      74      @return: 1 on success.75      @rtype: integer76      """77      object_handle = self._get_object_handle(window_name, object_name)78      object_handle.AXValue = 179      return 180   81   def setmin(self, window_name, object_name):82      """83      Set min value84      85      @param window_name: Window name to type in, either full name,86      LDTP's name convention, or a Unix glob.87      @type window_name: string88      @param object_name: Object name to type in, either full name,89      LDTP's name convention, or a Unix glob.90      @type object_name: string91      92      @return: 1 on success.93      @rtype: integer94      """95      object_handle = self._get_object_handle(window_name, object_name)96      object_handle.AXValue = 097      return 198   99   def scrollup(self, window_name, object_name):100      """101      Scroll up102      103      @param window_name: Window name to type in, either full name,104      LDTP's name convention, or a Unix glob.105      @type window_name: string106      @param object_name: Object name to type in, either full name,107      LDTP's name convention, or a Unix glob.108      @type object_name: string109      110      @return: 1 on success.111      @rtype: integer112      """113      if not self.verifyscrollbarvertical(window_name, object_name):114         raise LdtpServerException('Object not vertical scrollbar')115      return self.setmin(window_name, object_name)116   117   def scrolldown(self, window_name, object_name):118      """119      Scroll down120      121      @param window_name: Window name to type in, either full name,122      LDTP's name convention, or a Unix glob.123      @type window_name: string124      @param object_name: Object name to type in, either full name,125      LDTP's name convention, or a Unix glob.126      @type object_name: string127      128      @return: 1 on success.129      @rtype: integer130      """131      if not self.verifyscrollbarvertical(window_name, object_name):132         raise LdtpServerException('Object not vertical scrollbar')133      return self.setmax(window_name, object_name)134   def scrollleft(self, window_name, object_name):135      """136      Scroll left137      138      @param window_name: Window name to type in, either full name,139      LDTP's name convention, or a Unix glob.140      @type window_name: string141      @param object_name: Object name to type in, either full name,142      LDTP's name convention, or a Unix glob.143      @type object_name: string144      145      @return: 1 on success.146      @rtype: integer147      """148      if not self.verifyscrollbarhorizontal(window_name, object_name):149         raise LdtpServerException('Object not horizontal scrollbar')150      return self.setmin(window_name, object_name)151   152   def scrollright(self, window_name, object_name):153      """154      Scroll right155      156      @param window_name: Window name to type in, either full name,157      LDTP's name convention, or a Unix glob.158      @type window_name: string159      @param object_name: Object name to type in, either full name,160      LDTP's name convention, or a Unix glob.161      @type object_name: string162      163      @return: 1 on success.164      @rtype: integer165      """166      if not self.verifyscrollbarhorizontal(window_name, object_name):167         raise LdtpServerException('Object not horizontal scrollbar')168      return self.setmax(window_name, object_name)169   def onedown(self, window_name, object_name, iterations):170      """171      Press scrollbar down with number of iterations172      173      @param window_name: Window name to type in, either full name,174      LDTP's name convention, or a Unix glob.175      @type window_name: string176      @param object_name: Object name to type in, either full name,177      LDTP's name convention, or a Unix glob.178      @type object_name: string179      @param interations: iterations to perform on slider increase180      @type iterations: integer181      182      @return: 1 on success.183      @rtype: integer184      """185      if not self.verifyscrollbarvertical(window_name, object_name):186         raise LdtpServerException('Object not vertical scrollbar')187      object_handle = self._get_object_handle(window_name, object_name)188      i = 0189      maxValue = 1.0 / 8190      flag = False191      while i < iterations:192         if object_handle.AXValue >= 1:193            raise LdtpServerException('Maximum limit reached')194         object_handle.AXValue += maxValue195         time.sleep(1.0 / 100)196         flag = True197         i += 1198      if flag:199         return 1200      else:201         raise LdtpServerException('Unable to increase scrollbar')202   203   def oneup(self, window_name, object_name, iterations):204      """205      Press scrollbar up with number of iterations206      207      @param window_name: Window name to type in, either full name,208      LDTP's name convention, or a Unix glob.209      @type window_name: string210      @param object_name: Object name to type in, either full name,211      LDTP's name convention, or a Unix glob.212      @type object_name: string213      @param interations: iterations to perform on slider increase214      @type iterations: integer215      216      @return: 1 on success.217      @rtype: integer218      """219      if not self.verifyscrollbarvertical(window_name, object_name):220         raise LdtpServerException('Object not vertical scrollbar')221      object_handle = self._get_object_handle(window_name, object_name)222      i = 0223      minValue = 1.0 / 8224      flag = False225      while i < iterations:226         if object_handle.AXValue <= 0:227            raise LdtpServerException('Minimum limit reached')228         object_handle.AXValue -= minValue229         time.sleep(1.0 / 100)230         flag = True231         i += 1232      if flag:233         return 1...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!!
