omkarcloud / botasaurus

The All in One Framework to build Awesome Scrapers.
https://www.omkar.cloud/botasaurus/
MIT License
1.16k stars 104 forks source link

get_elements_or_none_by_xpath bug - uses CSS_SELECTOR instead of XPATH #31

Closed Aduomas closed 6 months ago

Aduomas commented 6 months ago

I believe there was an oversight issue of using the wrong By. ENUM parameter for this function.

file: anti_detect_driver.py

def get_elements_or_none_by_xpath(self: WebDriver, xpath, wait=Wait.SHORT):
        try:
            if wait is None:
                return self.find_elements(By.XPATH, xpath)
            else:
                WebDriverWait(self, wait).until(
                    EC.presence_of_element_located((By.CSS_SELECTOR, xpath))
                )

                return self.find_elements(By.XPATH, xpath)
        except:
            return None

the line EC.presence_of_element_located((By.CSS_SELECTOR, xpath))

should be changed to: EC.presence_of_element_located((By.XPATH, xpath))

Chetan11-dev commented 6 months ago

Thanks, will fix in upcoming release

Chetan11-dev commented 6 months ago

fixes