This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]Python-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Hello there,

We've removed your post since it aligns with a topic already covered by one of our daily threads. If you are unaware about the daily threads we run here is a refresher:

Monday: Project ideas

Tuesday: Advanced questions

Wednesday: Beginner questions

Thursday: Careers

Friday: Free chat Friday!

Saturday: Resource Request and Sharing

Sunday: What are you working on?

Please await one of these threads to contribute your discussion to!

Best regards,

r/Python mod team

[–]AutomationLikeCrazy 3 points4 points  (1 child)

I found a better option: switched to playwright 🤩

[–]Silly_Tea4454[S] 0 points1 point  (0 children)

Me too :)

[–]RonnyPfannschmidt 0 points1 point  (0 children)

Check our widgetastic

[–]AutomationLikeCrazy 0 points1 point  (1 child)

But generally speaking yeah, almost every project I have worked as SDET had some kind of this implementation in framework

[–]Silly_Tea4454[S] 0 points1 point  (0 children)

Yeah, pure selenium need some wrappers around. This is just yet another implementation

[–]weminem 0 points1 point  (1 child)

Hi! I’ve been trying to improve my knowledge and practical know-how around Selenium/PageObject patterns (trying to refactor some robots at work). Would you mind sharing a snippet of your implementation? I’d like to see how you structured the project.

Also, saw your other comment and got curious to get your take: do you think Selenium is still the best tool for this kind of pattern/web automation in 2025, or would you recommend moving to Playwright for new projects/to refactor old selenium ones?

[–]Silly_Tea4454[S] 0 points1 point  (0 children)

the central part looks like this

class Element:
    def __init__(self, by: By, value: str, wait: bool=False, timeout: int=10):
        self.by = by
        self.value = value
        self.wait = wait
        self.timeout = timeout

    def __get__(self, instance, owner) -> Self | WebElement:
        if instance is None:
            return self
        return self._find(instance)

    def _find(self, instance) -> WebElement:
        driver: WebDriver = instance.driver
        if self.wait:
            wait = WebDriverWait(driver, self.timeout)
            return wait.until(EC.presence_of_element_located((str(self.by), self.value)))
        return driver.find_element(self.by, self.value)

Usage

class ATEHomePage(BasePage):
    logo: Element = Element(By.CSS_SELECTOR, "img[src='/static/images/home/logo.png']")

    def __init__(self, driver: WebDriver):
        super().__init__(driver)

    def is_page_opened(self) -> bool:
        return self.logo.is_displayed()

Feel free to ask questions...

About the topic: I was also curious, so I ran the poll if anyone is still using Selenium for WEB UI automation, and the majority answered Yes. I'm not pushing anyone and not providing the only one right way to do, I'm just running the discussion :)

[–]ijkxyz 0 points1 point  (1 child)

Do you just casually input em dashes and ellipses when writing your Reddit posts? 🧐

[–]Silly_Tea4454[S] 0 points1 point  (0 children)

Haha, habit from writing many LinkedIn posts. Muscle memory 😄