Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get xpath of element selenium python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

#your executable_path will be different!!
driver = webdriver.Chrome(executable_path="C:/Development/chromedriver.exe")


driver.get("https://www.linkedin.com/jobs/search/?currentJobId=3271146120&f_AL=true&geoId=102257491&keywords=python%20developer&location=London%2C%20England%2C%20United%20Kingdom&refresh=true")

button = driver.find_element(By.XPATH, '/html/body/div[3]/header/nav/div/a[2]')
button.click()

email_field = driver.find_element(By.XPATH, '//*[@id="username"]')
password_field = driver.find_element(By.XPATH, '//*[@id="password"]')
sign_in_field = driver.find_element(By.XPATH, '//*[@id="organic-div"]/form/div[3]/button')
Comment

How to select element using xpath in python

# importing the HTMLSession class
from requests_html import HTMLSession
# create the object of the session
session = HTMLSession()
# url of the page
web_page = 'https://webscraper.io/'
# making get request to the webpage
respone = session.get(web_page)
# getting the html of the page
page_html = respone.html
# finding all divs which have h2 child using xpath
divs_parent_to_h2= page_html.xpath('//div//h2')
# printing the elements list
print(divs_parent_to_h2)Copy Code
Comment

PREVIOUS NEXT
Code Example
Python :: python buffer 
Python :: python coin flip 
Python :: python ternary operators 
Python :: how to inherit a class in python 
Python :: how to read a excel file in python 
Python :: python get all numbers between two numbers 
Python :: python how to find the highest even in a list 
Python :: Python Loop Usage 
Python :: show columns with nan pandas 
Python :: avoid self python by making class functions static 
Python :: Fun & learn with python turtle 
Python :: get list from list python 
Python :: dictionary lookup python 
Python :: what does tuple mean in python 
Python :: python vrer un fichier texte 
Python :: dictionaries in python 
Python :: partition python 
Python :: python function to do comparison between two numbers 
Python :: python inherit 
Python :: how to make a do while in python 
Python :: python sum of 10 numbers from user input 
Python :: print statements 
Python :: printing hello world in python 
Python :: create period pandas 
Python :: TypeError: view must be a callable or a list/tuple in the case of include(). 
Python :: beautifulsoup find element containing text 
Python :: python for loop inside list 
Python :: show only lower diagonal in sns pairplot 
Python :: import .dat python 
Python :: emacs pipenv not working 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =