You should use class and/or id to make shorter xpath.
When you find cards then you can use every card with xpath which starts with ./ - so it will be xpath relative to this element and it will search only inside this element.
You can also use // in any part of xpath to skip some tags which are not important.
You can use other find_element_by_ and find_elements_by_ with card and it will also search only inside this element - so it will be relative.
import selenium.webdriver
driver = selenium.webdriver.Chrome() # Firefox()
driver.get('https://travel.padi.com/s/liveaboards/caribbean/')
all_cards = driver.find_elements_by_xpath('//div[@class="boat search-page-item-card "]')
for card in all_cards:
title = card.find_element_by_xpath('.//a[@class="shop-title"]/span')
desc = card.find_element_by_xpath('.//p[@class="shop-desc-text"]')
price = card.find_element_by_xpath('.//p[@class="cur-price"]/strong/span')
print('title:', title.text)
print('desc:', desc.text)
print('price:', price.text)
all_dates = card.find_elements_by_css_selector('.cell.date')
for date in all_dates:
day, month = date.find_elements_by_tag_name('span')
print('date:', day.text, month.text)
print('---')
Example result (you can have price in different currency)
title: CARIBBEAN EXPLORER II
desc: With incredible, off-the-beaten path itineraries that take guests to St Kitts, Saba and St Maarten, this leading liveaboard spoils divers with five dives each day, scenic geography and a unique slice of Caribbean culture.
Dates do not match your search criteria
price: PLN 824
date: 7 DEC
date: 14 DEC
date: 21 DEC
date: 28 DEC
---
title: BAHAMAS AGGRESSOR
desc: Featuring five dives a day, the well-regarded Bahamas Aggressor liveaboard is the ideal choice for divers who want to spend as much time under the water as possible then relax in an onboard Jacuzzi.
Dates do not match your search criteria
price: PLN 998
date: 7 DEC
date: 14 DEC
date: 21 DEC
date: 28 DEC
---
div. And you can use//to skip some elements inxpath. To use relative path you have to start with dot./and use some other element instead ofbrowser- ieelem2[0].xpath('.//div')