Do I need a local install of Firefox if using Firefox driver in Selenium?

Do I need a local install of Firefox if using Firefox driver in Selenium?

I'm using Librewolf as my personal browser, in my script I'm using Firefox driver, do I need to install Firefox in my machine in order for the driver to work "better"? I have a Python + Selenium app to get URL data from a Read more, it has 35 pages, the script worked for the first 2 pages, on the third gave me en error (class attribute missing). Do I need to give it more wait time? The attribute I'm trying to get is FS03250425_BCN03A20 from

<div class="costa-itinerary-tile FS03250425_BCN03A20" data-cc-cruise-id="FS03250425_BCN03A20">

Is there a better way to do it? And this is the code I'm using

select_url_css = "data-cc-cruise-id"
select_tile_css = "div.costa-itinerary-tile"
element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, select_tile_css)))
elements = driver.find_elements(By.CSS_SELECTOR, select_tile_css)
   for element in elements:
       url_raw = element.get_attribute(select_url_css)

Answer

As far as I know, you should have the browser installed, as I believe the driver is just supposed to be used to control the browser... though your success with it working without it makes me doubt that theory.

As for the missing class attribute issue... hmm, it's possible that the class isn't there OR it's not parsing the .html correctly. Have you used driver.page_source to verify that attribute exists in the html when selenium gets it? You can do that by waiting for it to fetch the third page, then do print(driver.page_source). Warning: it will be a LOT of output, so you might just want to save that output to a file, then do

cat file.txt | grep FS03250425_BCN03A20

to see if it's where you expect it.

Enjoyed this article?

Check out more content on our blog or follow us on social media.

Browse more articles