How to input a float number using 'Input Text' from Selenium2Library

557 views Asked by At

I have a field which requires me to input a float number on a free text field. I read the float number from excel. However, I could not input the float number as I keep getting this error

"TypeError: object of type 'float' has no len()"

Let say I'm trying to put value 300.99 into a text box..

Do I need to convert into anything first?

2

There are 2 answers

1
Maninder On

According to me, you need to modify the format of excel cell, where you wrote the value 300.99. By default, the cell is formatted to General format. If you need to read a float value from a cell then change the format to Text from General.

Now driver will read a text value (300.99) from that field and pass it as it is. You can change the format by right click on the excel cell (cell from where you are reading value)>>Format cells>>Click on Text>> Ok.

Please let me know if this is helpful

Thanks!!

0
Lubos Jerabek On

You could also go for following one:

${var} =    Convert To String    ${var}
Log    ${var}

or

Log    ${var.__str__()}