'xpath issue using selenium

I am trying to scrape title but they say your xpath is wrong

from selenium.webdriver.common.by import By
from selenium import webdriver
from time import sleep

PATH="C:\Program Files (x86)\chromedriver.exe"
url='https://www.nationalhardwareshow.com/en-us/attend/exhibitor-list.html'
driver =webdriver.Chrome(PATH)
driver.get(url)
sleep(2)
def searchplace():
    vid = driver.find_elements(By.XPATH, "//div[@class='row']")
    for item in vid:
        title=item.find_element_by_xpath(".//div[@class='company-info']//h3").text
        print(title)
searchplace()


Solution 1:[1]

The below xpath worked for me give a try. Also try to reduce the xpath length efficiently if you need.

vid = driver.find_elements(By.XPATH, "//div[@class='directory-item directory-item-feature-toggled exhibitor-category']")
for item in vid:
    title=item.find_element(By.XPATH, "div[@class='row']/div[2]/div//div[@class='company-info']/div/a/h3")
    print(title.text)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vignesh