I have multiple elements with the same class_name (table-number). I am trying to find specific ones based on their sequence. In this case [1], the first one that appears in the DOM.
Here is working code:
my_table = driver.find_element_by_xpath("(//span[@class='table-number'])[1]").text
However, I am getting the following error:
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
I know I can ignore it, but it's annoying. I tried different syntax, such as:
my_table = driver.find_element(By.XPATH, ("(//span[@class='table-number'])[1]").text
my_table = driver.find_element(By.XPATH, "(//span[@class='table-number'])[1]").text
What should be correct syntax? Am I approaching it the wrong way?