How to convert string returning from get text() to tuple?

  • My tests are comparing two values to make sure value getting from locator should not be less or equal to expected value.

    Expected value returning from element.getText method is (0.00, 0.00) and actual value is (0.82, 0.43). These are tuples but element.getText method is returning string. If I use get_attribute("innerHTML") it's returning (u'(', u'0', u'.', u'8', u'2', u',', u' ', u'0', u'.', u'4', u'3', u')')

    Not sure what to use, element.getText or get_attribute("innerHTML")?

  • I think you can just converta tuple to a string and compare them:

    # Python3 code to convert tuple  
    # into string 
    def convertTuple(tup): 
        str =  ''.join(tup) 
        return str
    # Driver code 
    tuple = ('g', 'e', 'e', 'k', 's') 
    str = convertTuple(tuple) 


Suggested Topics