r/SeleniumPython • • Jan 11 '23

What am I not understanding about Selenium?

1 Upvotes

hello. this is kind of a desperation/frustration post.

i consider myself pretty intermediate when it comes to Python but every attempt at writing a test is met with a brick wall.

so here's an example. maybe someone can give me some insight about what i'm not understanding about Selenium and how to approach it. telling me what specifically i'm doing wrong would be great, too, but i'm really wondering just why this isn't clicking for me in a broader sense.

example:

i am developing a Django web app. i am testing the accounts app. here is one test and it works fine:

class LoginFormTest(LiveServerTestCase):

    @classmethod
    def setUpClass(cls) -> None:
        super().setUpClass()
        cls.driver = webdriver.Firefox(
            service=FirefoxService(GeckoDriverManager().install()))
        cls.driver.implicitly_wait(10)
        cls.user = User.objects.create_user(
            username="test_user",
            password="test_password",
        )
        cls.user_id = cls.user.pk

    @classmethod
    def tearDownClass(cls) -> None:
        cls.driver.quit()
        super().tearDownClass()

    def test_login(self):
        """
            Simple login loop:
            - start at index, click on login link, enter credentials, submit.
        """
        self.driver.get(self.live_server_url + reverse_lazy('base:index'))
        login_link = self.driver.find_element(by=By.LINK_TEXT, value="Login")
        login_link.click()

        username_input = self.driver.find_element(by=By.ID, value="id_username")
        password_input = self.driver.find_element(by=By.ID, value="id_password")
        submit_input = self.driver.find_element(by=By.CSS_SELECTOR, value="input[type='submit']")

        username_input.send_keys('test_user')
        password_input.send_keys('test_password')
        submit_input.click()

        expected_url = self.live_server_url + reverse_lazy('accounts:profile', args=[self.user_id])
        actual_url = self.driver.current_url    # FULL url including host 
        self.assertEqual(actual_url, expected_url)

however, when i pretty much copy and paste this functioning test to do the same thing, but with user registration, it fails.

class RegistrationTest(LiveServerTestCase):

    @classmethod
    def setUpClass(cls) -> None:
        super().setUpClass()
        cls.driver = webdriver.Firefox(
            service=FirefoxService(GeckoDriverManager().install()))
        cls.driver.implicitly_wait(10)

    @classmethod
    def tearDownClass(cls) -> None:
        cls.driver.quit()
        super().tearDownClass()

    def test_registration(self):
        self.driver.get(self.live_server_url + reverse_lazy('base:index'))
        login_link = self.driver.find_element(by=By.LINK_TEXT, value="Register an account")
        login_link.click()

        username_input = self.driver.find_element(by=By.ID, value="id_username")
        password_input1 = self.driver.find_element(by=By.ID, value="id_password1")
        password_input2 = self.driver.find_element(by=By.ID, value="id_password2")
        submit_input = self.driver.find_element(by=By.NAME, value="submit")

        username_input.send_keys("test_user")
        password_input1.send_keys("vTooGyk5")
        password_input2.send_keys("vTooGyk5")
        submit_input.click()

        expected_url = self.live_server_url + reverse_lazy('accounts:login')
        actual_url = self.driver.current_url
        
        self.assertEqual(expected_url, actual_url)   

the relevant lines of the error message:

selenium.common.exceptions.ElementNotInteractableException: Message: Element <input class="btn btn-primary px-4" name="submit" type="submit"> could not be scrolled into view

the important difference is that the registration page has a scroll bar, so the submit button is initially out of view.

things i have tried:

submit_input = WebDriverWait(
    self.driver, 100).until(
        EC.element_to_be_clickable(submit_input))
submit_input.click()

Result: same error.

==========================================

ActionChains(self.driver).move_to_element(submit_input).click(submit_input).perform()

Result: different error:

selenium.common.exceptions.MoveTargetOutOfBoundsException: Message: (440, 1052) is out of bounds of viewport width (1477) and height (722)

==========================================

Attempted a workaround by over-scrolling to an object below the submit button:

footer = self.driver.find_element(by=By.CSS_SELECTOR, value="footer")
a = ActionChains(self.driver)
a.move_to_element(footer)
a.perform()
submit_input.click()

Error: same out of bounds error.

==========================================

Finally, I have tried the solution presented here: https://9to5answer.com/selenium-movetargetoutofboundsexception-with-firefox Result: same out of bounds error.

==========================================

so what am is going on? what am i not understanding about how Selenium works?


r/SeleniumPython • • Dec 29 '22

Selenium problems

1 Upvotes

I need help... I am using a python program to send parameters to the Spain e-administration site to get an appointment for a procedure. But the page is blocking my session: The requested URL was rejected. Please consult with your administrator.

Your support ID is: <1417176221212705327608>. .

I was reading some solutions, and I saw that using sleep.time() I could simulate the writing of a human so that the page doesn't crash. But it didn't work. Can anyone think of something else?


r/SeleniumPython • • Oct 03 '22

How can we get the XY location of a particular div tag so that we can click on it? What i want to do is to click on that tag and drag my mouse to the other div tags using mouse module . Help me with your suggestions

1 Upvotes

r/SeleniumPython • • Jul 10 '26

Help Browser automation for Workday and avoiding captcha

Thumbnail reddit.com
0 Upvotes

r/SeleniumPython • • Jun 25 '26

Python Mphasis python automation interview questions and experience

0 Upvotes

r/SeleniumPython • • Feb 23 '26

Pro Tip: Android user-agent makes the page load lightweight

0 Upvotes

If you are intersted improve the optimization and faster load in head mode it would be good put an android user agent. Why? Mainly for the image size wich are smaller and other stuffs

The user-agent i use:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, como Gecko) Chrome/135.0.0.0 Safari/537.36

r/SeleniumPython • • Feb 20 '26

Selenium THIS is the DOCKERFILE i use in my VPS for webscrapping with undetected_chromedriver (inherts from selenium)

0 Upvotes

"Dockerfile" file content:

FROM python:3.10-alpine


EXPOSE 5900


COPY ./requirements.txt /tmp/requirements.txt
COPY ./app /app
COPY ./scripts /scripts


# Install temporary dependencies
RUN apk update && apk upgrade && \
    apk add --no-cache --virtual .build-deps \
    alpine-sdk \
    curl \
    python3 \
    wget \
    unzip \
    gnupg 


# Install dependencies
RUN apk add --no-cache \
    xvfb \
    x11vnc \
    fluxbox \
    xterm \
    libffi-dev \
    openssl-dev \
    zlib-dev \
    bzip2-dev \
    readline-dev \
    git \
    nss \
    freetype \
    freetype-dev \
    harfbuzz \
    ca-certificates \
    ttf-freefont \
    chromium \
    chromium-chromedriver



# Install Python dependencies
RUN pip install --no-cache-dir -r /tmp/requirements.txt && \
    rm /tmp/requirements.txt


WORKDIR /app


# RUN chmod -R +x /scripts


# ENV PATH="/scripts:$PATH"
# ENV DISPLAY=:0
ENV PYTHONUNBUFFERED=1 \
    PYTHONHASHSEED=random \
    MEMORY_LIMIT="512M"


# Delete temporary dependencies
RUN apk del .build-deps


CMD ["python3", "main.py"]

"docker-compose.yml" file:

version: '3.1'
services:
  chrome:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 5900:5900
    volumes:
      - ./app:/app
    shm_size: '2g'

r/SeleniumPython • • Sep 02 '25

Help with my code

Thumbnail
gallery
0 Upvotes

Hola quería preguntarles PQ mi código no reconoce el Select, ya use el ID, lo busque por el value, y por xpath pero no me reconoce el código.. únicamente necesito que el Select me seleccione el value 1 (siempre será ese valor) alguien me puede ayudar? O si saben dónde puedo ver tutoriales de esto


r/SeleniumPython • • Sep 02 '25

Suggest me few demo websites for Automation testing using pytest framework

0 Upvotes