0
<button class="button" style="styles">TEXT</button>

How do I find this element in a website using Selenium PhantomJS?

Tejesh
  • 13
  • 1
  • 1
    What do you mean find it without any indication? Is like looking for a person without knowing his/hers name/look/Id. Possible duplicate - https://stackoverflow.com/questions/27529967/how-to-find-button-element-with-webdriver/39594489 – CloudBalancing Dec 10 '20 at 09:33

1 Answers1

0

You can use the XPATH, ro the element you want to find by using:

from selenium.webdriver.common.by import By

myButton = driver.find_element(By.XPATH, '//button[text()="Some text"]')

But using the XPATH is not the best practice sinze it can change if the html changes.

Other way to lacate it is using the tag "button":

myButton = driver.find_element_by_tag_name('button')

or the class:

myButton = driver.find_element_by_class_name('button')

There are several ways to find it, you can check them here:

enter link description here

Sergio García
  • 486
  • 5
  • 15