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 • • Jul 11 '23

Help DeprecationWarning: Setting a profile has been deprecated

1 Upvotes

I get this warning with:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.profile = '/path/to/jenny-profile'
options.add_argument('-headless')
browser = webdriver.Firefox(options=options)

DeprecationWarning: Setting a profile has been deprecated. Please use the set_preference and install_addons methods

But I can't seem to get the right new non deprecated install_addons methods to load the profile. The above code works and I'm using it in production because, wow, it works! But would love to solve this error soon. Thanks!


r/SeleniumPython • • Jul 20 '23

Xpath RPA Significance in Healthcare Operations

Thumbnail
testorigen.com
1 Upvotes

r/SeleniumPython • • Mar 08 '23

After I click on a button a new url is opened within the same tab then selenium cannot find any elements

1 Upvotes

I’ve tried this so far all this code is only an example Button.click() Time.sleep(10) currenturl = driver.current_url Driver.get(currenturl)

continue on new url

Last4 = driver.find_element(By.ID, ‘last4of’) Last4.sendkeys(la4)

on the last 4 part of my code the bot does nothing doesn’t even return a error till I stop running the script then it gives the errors could not find element and errors surrounding the currenturl


r/SeleniumPython • • Jul 22 '23

Selenium Python/Selenium Script To Remove All Reddit Comments

Thumbnail self.learnpython
1 Upvotes

r/SeleniumPython • • Jun 19 '23

Hey, I’m a beginner learning selenium and I have a doubt which I’m not able to find online. Can anyone help me with that?!

1 Upvotes

r/SeleniumPython • • May 15 '24

Chrome driver, creates lots of background processes.

4 Upvotes

I've some python code that scrapes data from the web using selenium with chrome webdriver. This worked nicely till 2 months or so ago. Suddenly it started slowing down my computer in the extreme. The problem occurs with different projects, so it doesn't seem to be the code as the code of some of these projects has not changed in this time period. When I look at in windows task manager it shows that the CPU at 100% and a huge number chrome background processes.

Anybody know what may cause this sudden change and what may be done to solve it?


r/SeleniumPython • • Feb 13 '24

Run Selenium on Windows and MacOS devices without installing software?

2 Upvotes

Is it possible to run a Selenium script on a device without installing software or browser extension?

The aim is to screen share with the user of the remote device. They will be running as a standard user without the privileges required to install software, they will also not be allowed to install anything else such as browser extensions. The script should open a browser and go to a URL. The mouse should then make a series of clicks on the application. Ideally this would also be recorded within the script itself and accessible from the cloud server, worst case is it would be saved locally.

Perhaps Selenium isn’t the answer, any suggestions are more than welcome.

I have been able to use BrowserStack to record a script and then run on my device, but I had to install software on my device to do so.


r/SeleniumPython • • Jul 27 '23

Meme Solving problems in Software Testing can be one of the most satisfying jobs 🙌🏻

3 Upvotes

r/SeleniumPython • • Sep 04 '23

Help Different Game Testing Methods

Thumbnail
testorigen.com
1 Upvotes

r/SeleniumPython • • Jun 30 '24

can you give me repo selenium python to refer ??

2 Upvotes

r/SeleniumPython • • Apr 23 '24

Bypass Microsoft Login

1 Upvotes

So in my company i have the task to test synthetic monitorings for our websites, but these internal website mostly need an authentication (Azure AD) and i dont know how to implement code to access the website behind the authentication. Can somebody guide me please?


r/SeleniumPython • • Jun 14 '23

Help Problem with search box

Thumbnail wozwaardeloket.nl
1 Upvotes

I have been trying to get the WOZ information from a Dutch website. This data is in a sidebar and is loaded after you paste a postcode after which some of the addresses are displayed along with a show all button. When the show all is clicked it displayed all addresses in that postcode as buttons which can be clicked individually. The website can be found here: Https://wozwaardeloket.nl

I am able to make selenium click on the first button that appears in a dialogue box when you load the webpage. But am unable to get the search box to paste a value and retrieve addresses.

An example postcode for you to try could be 2628PZ

Please help me to find a way to enter postcodes in the search box and retrieve addresses.


r/SeleniumPython • • Sep 08 '21

r/SeleniumPython Lounge

2 Upvotes

A place for members of r/SeleniumPython to chat with each other