r/SeleniumPython • • Feb 09 '24

Screen resolution issue in switching window

1 Upvotes

I automated window switching with the "switch_to_window" method along with some validation using selenium python. And now whenever I run my test suite in headless=new mode, the second window opens with a screen resolution of 1024*728.

I have used options.add_argument(size) to set the window size to 19201080 while running in headless new mode. It seems to work because my main window is opening with 19201080, but the second window is getting this weird screen resolution. Can anyone please help me?


r/SeleniumPython • • Feb 03 '24

Help Can’t figure out Autocomplete on Via.com

1 Upvotes

Hey Folks! I am trying to automate the flight booking process on Via.com but I can’t get past the Source and Destination autocomplete dropdowns. Can someone help me out please?


r/SeleniumPython • • Jan 30 '24

Help Code doesn’t work when browser is minimized

1 Upvotes

The selenium code works when the browser tab is visible on screen, but doesn’t when the tab is minimized.

On macOS running geckodriver for firefox, selenium code calls execute_script a lot to run javascript.

Is this a common issue? (and if so how would I avoid this?)


r/SeleniumPython • • Jan 23 '24

Inserting HTML as formatted text with active link

1 Upvotes

How do I insert HTML text as formatted text with active links into CK-Editor, which doesn't have custom HTML insertion?


r/SeleniumPython • • Jan 22 '24

Help Unable to discover proper chromedriver version in offline mode in Docker Web App (Azure)

1 Upvotes

I'm running a web app on Azure from a Docker container based on a Selenium image (selenium/standalone-chrome:latest). It ran perfectly fine, but out of nowhere (after changing something unrelated in the data handling section separate from my scraper) started giving me the following error: "Unable to discover proper chromedriver version in offline mode".

The weird thing is that my API is still running fine online; I can get and post requests and from my logs I can see they're received and handled properly up until the chromedriver is initiated (which fails).

The error occurs here during the instantiation of the driver:

# import chromedriver_binary

from selenium.webdriver import Chrome, ChromeOptions

def _GetDriver() -> Chrome:

options = ChromeOptions()

options.add_argument("--headless")

options.add_argument('--disable-gpu')

options.add_argument('--no-sandbox')

return Chrome(options=options) # <--- Error happens here.

def _EnrichAtomicAddress(info: dict) -> dict:

with _GetDriver() as driver: # <--- Only place _GetDriver is called.

data = XXXXXX(driver, info)

data['lastScrapedDate'] = date.today()

data['retrievalDate'] = date.today()

if 'errorMessage' in data:

return data

data.update(XXXXX(driver, data))

return data

My Dockerfile:

FROM selenium/standalone-chrome:latest

LABEL authors="Robert"

# Set the working directory to /app

WORKDIR /app

# Copy the current directory contents into the container at /app

COPY . /app

# Install any needed packages specified in requirements.txt

RUN sudo apt-get install -y python3

RUN sudo apt-get update && sudo apt-get install -y python3-pip

RUN sudo pip install --no-cache-dir -r requirements.txt

# Ports

EXPOSE 443

EXPOSE 80

# Define environment variable

ENV FLASK_APP function_app.py

# Run the Flask app

# CMD ["flask", "run", "--host=0.0.0.0"]

CMD ["flask", "run"]

\# ENTRYPOINT ["top", "-b"]```

I've tried:

- different selenium image versions;

- different selenium images (chrome, edge, firfox, etc) also changing the corresponding webdriver instantiation in Python;

- including my own chromedriver via the Python package chromedriver-binary;

- removing all the chrome options I have set for in _GetDriver();

- reverting the unrelated code chance

yet to no avail.

What is causing this and how can I fix this? Thanks in advance! <3


r/SeleniumPython • • Jan 18 '24

selenium err_http2_protocol_error

1 Upvotes

Hey, have a Self written Python Ticket bot for Eventim. It worked for the last years. Since a week I get a err_http2_protocol_error on the webpage when using the bot. This happens on all Eventim websites. Does anyone know how to bypass and avoid that? Tried a lot, but nothing worked so far…


r/SeleniumPython • • Jan 17 '24

Having trouble selecting a radio button in a website!! Bugging me for two days. Can somebody help me choose the right element for my python program

1 Upvotes

r/SeleniumPython • • Jan 10 '24

Selenium - Can't extract text from item using "driver.find_element(By.CLASS_NAME "class name")

1 Upvotes

I am trying to extract the text content of a using the CLASS_NAME method, and even though the is the only element with that class, when I assign the text of the span to a variable and print said variable, what gets printed is a return line.

The structure of the page is the following:

• There is the most outer that contain basically any information I need, which I was able top identify with the following snippet:

#Only One with this classed
main_div = driver.find_element(By.CLASS_NAME,"//div[@class='am-appointments am-section']")

Inside of previous there a variable number of other that compartmentalize the informations I am seeking on a date basis, so each day has it own day. , which I was able top identify with the following snippet:

child_divs = main_div.find_elements(By.XPATH,"./div[not(contains(@class, 'am-appointments-list-head') or contains(@class, 'am-pagination am-section'))]")

with the former command I extracted a list of these child , each one of them has again a variable number of and each on of these contains the informations I need. So I ran a for loop like this:

for child_div in child_divs:

appointments=child_div.find_elements(By.XPATH,"//div[@class='am-appointments-list']//div[@class='el-collapse']//div[contains(@class, 'el-collapse-item am-appointment am-back-appointment') or contains(@class, 'el-collapse-item am-appointment am-front-appointment')]")

for appointment in appointments:
    phone=appointment.find_element(By.CLASS_NAME, "am-appointment-data-phone")
    phone_text=phone.text

I created again a list of all the inside each child_div, and ran again the loop, to find and extract the phone number from a < span> that has the following features:

<span class="am-appointment-data-phone">+393314569013</span>

Even though the I am targeting in this final step is the only item with this class, the script doesn't print anything. So I guess somehow doesn't get assigned to the variable 'phone_text'. The < span> I am targeting is part of an animation, you click the button, the module expands and it's visible, or maybe there's some interference with Javascript ? I really don't understand what could be the issue. Thank you for anyone who can help!


r/SeleniumPython • • Jan 04 '24

Hey everyone! I'm new here, I have a project to do and I have some problems I need help to bypass the captcha with Selenium

1 Upvotes

I used undetected_chromedriver but this is still target me


r/SeleniumPython • • Dec 31 '23

Selenium What is a "W3C WebDriver-compatible clients" in relation to Selenium

1 Upvotes

I'm reading this article about Geckodriver proxy http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/ and he says that

Geckodriver is a proxy for using W3C WebDriver-compatible clients to interact with Gecko-based browsers i.e. Mozilla Firefox in this case. This program provides the HTTP API described by the WebDriver protocol to communicate with Gecko browsers. It translates calls into the Marionette automation protocol by acting as a proxy between the local and remote ends.

So is geckodriver a proxy between the browser and the selenium script? How can calls to extract data from a webpage sitting in the DOM of a browser translate to the HTTP API? Could someone explain what is going on between a selenium script and a browser that has loaded your webpage: how exactly does the selenium-python script extract the data within the DOM of the browser?


r/SeleniumPython • • Dec 19 '23

Login with "hidden" button - not working

1 Upvotes

Hello,

i am trying to log into https://shop.vfb.de/konto/#hide-registration using python and selenium.

Parsing mail and password is working fine...

How ever i can not manage to click the "Anmelden" Button because there is no ID or something i can search for...(maybe additional info: the button is changing the cullor if you put the mouse on it)

This is how the html is looking:

Anyone having a suggestion what I can do? Is there a working solution to work with such "hidden" buttons?

Thank you so much!!


r/SeleniumPython • • Dec 11 '23

Can't import user data when loading website using python script

Post image
1 Upvotes

r/SeleniumPython • • Nov 18 '23

Pyhton & Selenium find text

1 Upvotes

Hello everyone, I’m trying to use Selenium to find block of text 1 and block of text 2, but it gives an error that the text was not found. I specified it using a selector and xpath, but still doesn’t see it.

I am attaching the code and a picture of what you need to find

# Функция для поиска элемента по селектору ID
def find_element_by_id(driver, id):
    try:
        return WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.ID, id))
        )
    except TimeoutException:
        return None

# Функция для сравнения текста из двух элементов
def compare_text(text1, text2):
    # Преобразуем текст в нижний регистр, чтобы сделать сравнение более точным
    text1 = text1.lower()
    text2 = text2.lower()

    # Используем метод `similarity()` Bard API для сравнения двух текстов
    similarity = bard.similarity(text1, text2)

    # Возвращаем значение, указывающее, подходит ли текст
    return similarity >= 0.8

# Находим элемент 1
element_1 = find_element_by_id(driver, "#klecks-app > tui-root > tui-dropdown-host > div > task > flex-view > flex-common-view > div.tui-container.tui-container_adaptive.flex-common-view__main > div > main > flex-element > flex-container > flex-element:nth-child(1)")

# Находим элемент 2
element_2 = find_element_by_id(driver, "#klecks-app > tui-root > tui-dropdown-host > div > task > flex-view > flex-common-view > div.tui-container.tui-container_adaptive.flex-common-view__main > div > main > flex-element > flex-container > flex-element:nth-child(4)")

# Получаем текст из элементов
text1 = element_1.text
text2 = element_2.text

# Сравниваем текст
is_similar = compare_text(text1, text2)

# Выводим результат сравнения
if is_similar:
    result = "Тексты похожи"
else:
    result = "Тексты не похожи"

print(result)

r/SeleniumPython • • Oct 31 '23

selenium and tradingview

1 Upvotes

hello to all interested. I have been looking for a solution to my question for more than a month and have tried more than one option. I have my own tradingview strategy, its results depend on the selection of parameters. I want to find a way to automate the selection of parameters to find the most profitable combination. I used chat gpt to write code in python, it even worked as it should. but there was a problem with access to ccxt libraries for a maximum of 2-5 days depending on the exchange. now I am thinking about whether it is possible to solve my problem with the help of selenium.

anyone with a similar experience would love to hear your thoughts


r/SeleniumPython • • Oct 22 '23

Hving trouble scraping a web page

Thumbnail self.learnprogramming
1 Upvotes

r/SeleniumPython • • Oct 04 '23

selenium automation

1 Upvotes

Hey guys....I am using selenium python to automate ERP system but there is a 2F authentication which stops my automation. The 2F authentication usually requires the user to enter the SMS code they receive on their phone. Please let me know how I can bypass this?


r/SeleniumPython • • Sep 27 '23

How to separate multiple pricing options for one product in CSV?

1 Upvotes

Hi all, first time poster here. Been building a scraper for the past few days, but I am completely stuck on how to differentiate between pricing of options for the same product in my CSV. I can pull ALL of the pricing from the menu of items page, but then it will get them out of order in the python lists because pricing for one item with variations/options will end up taking up multiple spaces in the list, and make them match up with the wrong indexes of the item name/brand/etc.

Also, I can't find anything unique and in a pattern via ID, CLASS or XPATH to break the options' pricing up into their own list items.

Can anybody help?


r/SeleniumPython • • Sep 26 '23

Help [Help] I am not able to access "www.realestate.com.au" using requests & Selenium

1 Upvotes

I am trying to access this website: "www.realestate.com.au"

I can access it normally using my normal browser but I am not able to access it using:

  1. Requests (I accessed it in the start but now it is causing issues Error Code: 429)

  2. Selenium (It does not show anything. White blank page)

  3. Undetected Chrome Driver (It does not show anything. White blank page)

Can anybody check this website and tell me how can I access it and get some data from it?


r/SeleniumPython • • Sep 14 '23

Functions & Needs Bound to Object Recognition Software

Thumbnail
testorigen.com
1 Upvotes

r/SeleniumPython • • Sep 13 '23

Selenium Need help with selectors and text search

1 Upvotes

Consider the following code written in python:

Can anyone help me understand if there is anything wrong with my xpath query? It never reaches "found a free day!"

For context, here is what the html looks like:

Any help is very much appreciated.


r/SeleniumPython • • Sep 04 '23

Help Different Game Testing Methods

Thumbnail
testorigen.com
1 Upvotes

r/SeleniumPython • • Aug 30 '23

Selenium Demo Projects?

1 Upvotes

I’m looking for a sample project with a basic test suite that I could use when testing how to set up and configure Selenium Grid in a CI/CD pipeline. Is anyone aware of like a starter project I could just use vs writing my own?


r/SeleniumPython • • Aug 24 '23

Help How to handle Screen Recording pop-up?

1 Upvotes

This pop-up cannot be inspected, I need to click on 'Allow' & 'Cancel'.
I've tried using pyautogui (2 Tabs, then Enter), and even though that works, it may not always as the script can run into scenarios where the browser is minimized.

(As mentioned before, I am unable to inspect this pop-up content using Dev-tools or any other way)

Thanks in advance.