Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defining function in selenium
#3
(Jul-01-2020, 10:06 AM)Larz60+ Wrote: example:
from selenium import webdriver
from selenium.webdriver.common.by import By

...

browser.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[1]/div/svg/g[6]/image[133]')
you can get xpath by using your browsers 'copy' in 'inspect element'
if firefox:
  • with page you wish to scrape in browser, place cursor over item you want XPath for
  • right click and select 'Inspect Element'
  • Place cursor over highlighted code
  • Right click, select copy
  • select XPath
  • Paste into code

I know about how to extract data using selenium and xpath, but I want to define a function that does the job for me as I input the xpath of the element. Thank you so much for your reply.
Reply


Messages In This Thread
Defining function in selenium - by AgileAVS - Jul-01-2020, 09:22 AM
RE: Defining function in selenium - by Larz60+ - Jul-01-2020, 10:06 AM
RE: Defining function in selenium - by AgileAVS - Jul-01-2020, 01:09 PM
RE: Defining function in selenium - by musaab - Jul-01-2020, 01:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,664 Nov-03-2017, 08:41 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020