Skip to content

Tag: xpath

Getting text from a object with Selenium

I’m trying to get the text inside of <pre> tag and I have tried with get_attribute(‘text’), get_attribute(‘value’), .text(), .value(), get_attribute(“innerHTML”) but I keep failing: Snapshot: This is the code that i’m using: And this is what it says when print: Answer To print the text within the <pre> tag you can use either of the following locator strategies: Using css_selector

AttributeError: ‘WebElement’ object has no attribute ‘select_by_value’ selecting dropdown menu using Selenium

I am trying to find menu prices for certain fast food restaurants from this website by different state. There is a dropdown menu where different states are the options. After I select a state (for example, California), I want to web scrape the different prices of their Ice Cream. However, I keep getting the same error message preventing me from

Selenium / Use pagination on site?

i want to trigger the pagination on this site: I found the element with this XPATH in the chrome-inspector: Now i want to click this element to go one page further – but i get an error. This is my code: But i get this error: How can i go to the next page using selenium? Answer The go

Selenium Select the exact date from Datepciker

This is continuation of this question asked earlier Earlier question I am able to select the date but the problem arises in below scenarios when there is some dates like I tried using XPath not contains but I am getting more than 1 element identified. below is my code I want to select only the dates which are below how

Scrapy Python can‘t extract links with more stable xpath

I‘m Building a scraper for this website. I‘m using Python and scrapy Shell to extract the data that I want: xpath would be: //a[@class=“sb-card sb-card-company site-1×1 with-hover]/@href“ Using response.xpath(‘//a[@class=“sb-card sb-card-company site-1×1 with-hover]/@href“‘ returns [] I tried using contains(@class,“sb-card-company“) with the same result. Using other containers in the same way, changed nothing. Using a different page also had no effect. Using

Xpath: How to check if a tag comes before text or after text?

Assume I have the following two example pieces of HTML: <p>This is some text: <b>ABCD12345</b></p> <p><b>Name:</b> John Doe</p> I’m able to separate the <b> and non-<b> parts, but I (also) want to know how to determine whether the <b> part is at the start or at the end of the text (in other words; whether it has text before or

Search for a specific element in multiple pages and click using Python Selenium

Hi im trying to navigate from page 1 to page 5 (the element can be in any of the pages)and find and click on a specific element using python selenium. The following is the element from the page: <span _ngcontent-mtx-c123″” class”ng-star-inserted”>ABC Company</span> i tried by using : driver.find_element_by_name(“ABC Company”).click() but this doesnt work. Another Way i tried: I need the