Extract Specific text information from a Card with Selenium (python) - python

While using selenium to automate reverse address search I am unable to retrieve the information from a card in the DOM. When I copy the specific XPATH of the text not to my surprise its a text object instead of an element. Any solutions? image

Related

Extract text from mn/mo element in Selenium Python

I'd like to scrape a website and it has elements something like:
<mn>567</mn>
<mo>+</mo>
<mn>213</mn>
How do I extract the text from these elements using Selenium? [element].text does not seem to work.

Get Xpath for Element in Python

I've been researching this for two days now. There seems to be no simple way of doing this. I can find an element on a page by downloading the html with Selenium and passing it to BeautifulSoup, followed by a search via classes and strings. I want to click on this element after finding it, so I want to pass its Xpath to Selenium. I have no minimal working example, only pseudo code for what I'm hoping to do.
Why is there no function/library that lets me search through the html of a webpage, find an element, and then request it's Xpath? I can do this manually by inspecting the webpage and clicking 'copy Xpath'. I can't find any solutions to this on stackoverflow, so please don't tell me I haven't looked hard enough.
Pseudo-Code:
*parser is BeautifulSoup HTML object*
for box in parser.find_all('span', class_="icon-type-2"): # find all elements with particular icon
xpath = box.get_xpath()
I'm willing to change my code entirely, as long as I can locate a particular element, and extract it's Xpath. So any other ideas on entirely different libraries are welcome.

Get enclosing tag of text selenium

So, I know there's a bunch of ways to obtain an element on a webpage by looking up its tag in selenium, but I was wondering if it was possible to do the reverse. Can I obtain the immediate enclosing tag of some text that I look up on a page using selenium?

How to capture the text from web elements having different attributes into a list using selenium python

SnapshotI am trying to capture the text from a Webpage where the attributes is different for every element.
==== Attribute===
**NX-2896HCP**
Attached is the Snapshot of the Webpage
For some elements the attributes is same while for some it is different
Help will be appreciated

finding link element using selenium inside span

I am trying to get a csv file but selenium is not able to find the element
i am able to fill the form. website url is "https://www.nseindia.com/products/content/equities/equities/eq_security.htm"
to download the csv i have to click on element with text = Download file in csv format but it's not finding it.
print(browser.find_element_by_xpath('//*
#id="historicalData"]/div1/span[2]/a').click())
i have tried using css selector and link text, tag name but getting error not able to locate element.
link is highlighted here
So what you are going to need here is
browser.find_element_by_xpath('//a[contains(text(), 'Download file in csv format')]').click()
An absolute xpath, with a lot of elements in it, is very sensitive to change.

Categories