- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find and click element by title Python Selenium.
We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].
Let us take an html code for an element with a title attribute.
The xpath to identify the element should be //a[@title='Tutorialspoint'] and the css expression should be a[title='Tutorialspoint']. Once the element is identified we can use the click() method for clicking on it.
from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # implicit wait for 5 seconds driver.implicitly_wait(5) # maximize with maximize_window() driver.maximize_window() driver.get("https://www.tutorialspoint.com/about/about_careers.htm") # identify element with title attribute and click() l=driver.find_element_by_xpath("//a[@title='Tutorialspoint']") l.click() print("Current page title: " + driver.title) driver.quit()
- Related Articles
- Find Element and FindElements by XPath in Selenium
- How to perform double click on an element in Selenium with python?
- How to perform right click on an element in Selenium with python?
- Click a href button with Selenium and Python?
- How to click button Selenium Python?
- How to click on hidden element in Selenium WebDriver?
- How to perform double click on an element in Selenium?
- Find next sibling element in Selenium, Python?
- Is there a way to find an element by attributes in Python Selenium?
- Find Element and FindElements in Selenium
- Find div element by multiple class names in Selenium?
- How to click on image in selenium webdriver Python?
- How to perform right click on an element with Actions in Selenium?
- Difference between find Element and find Elements in Selenium