Skip to content
Advertisement

Tried several methods but this Value Error keeps popping up running with the WebDriver

Below is the part where my code program meets a runtime ValueError.

JavaScript

As I’m using selenium as part of the program, im taking webelements into a variable then convert the variable to a float number as it is on the website. Below is the error:

JavaScript

Tried several different methods to solve this ValueError but all didn’t really worked out.

Advertisement

Answer

This error message…

JavaScript

…implies that the variable ' ' cannot be converted to float as it is a blank.


Solution

Possibly the textContext wasn’t rendered when the line of code was executed. So to locate the element you need to induce WebDriverWait for the visibility_of_element_located() and you can use the following Locator Strategy:

  • Using XPATH:

    JavaScript
  • Note : You have to add the following imports :

    JavaScript
Advertisement