EDIT: If you want to test it on your control room, go ahead!! the code is in my github!
I really don’t understand how am I supposed to debug Robocorp errors. The error I’m having is:
error html
From what I can understand, It is having difficulties on activating the webdriver:
class CustomSelenium:
excel = ExcelManager()
def __init__(self) -> None:
self._driver = None
self._options = None
self._file = FileSystem()
self._picture_link_list = []
self._news_list = {
"title": [],
"date": [],
"description": [],
"picture_filename": [],
"phrase_count": [],
"contains_money": [],
}
# Data required by the challenge:
self.set_chrome_options()
self.set_webdriver()
def set_chrome_options(self):
if self._options is None:
self._options = ChromeOptions()
self._options.add_argument('--disable-dev-shm-usage')
# self._options.add_argument('--headless')
self._options.add_argument('--no-sandbox')
self._options.add_argument("--disable-extensions")
self._options.add_argument("--disable-gpu")
self._options.add_argument('--disable-web-security')
self._options.add_argument("--start-maximized")
self._options.add_argument('--remote-debugging-port=9222')
# Ads gives out size error
# self._options.add_argument('--window-size=1920x1080')
self._options.add_experimental_option("excludeSwitches", ["enable-logging"])
return self._options
def set_webdriver(self):
self._driver = webdriver.Chrome(options=self._options)
print("WebDriver initialized successfully.")
cs = CustomSelenium()
cs._driver.quit()
Imports:
from selenium.webdriver.remote.webelement import WebElement
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver import ChromeOptions
from selenium import webdriver
from selenium.webdriver.common.by import By
from RPA.FileSystem import FileSystem
from RPA.Browser.Selenium import Selenium
from typing import Tuple, Optional
from configurations_class import ConfigManager
from excel_class import ExcelManager
from selenium.common.exceptions import NoSuchElementException, ElementClickInterceptedException, TimeoutException, StaleElementReferenceException, ElementNotInteractableException
import time
import os
import re
import requests
from dateutil.relativedelta import relativedelta
from datetime import date, datetime, timezone
from robocorp import log
import logging
I would appreciate help, because robocorp is really bad at this..
[2024-08-15T20:31:07.560]: [0m======================== Full Traceback (running [96mmain[0m) =========================
...
"/home/worker/.robocorp/holotree/db8072d_b5db08f_79335166/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
[2024-08-15T20:31:07.564]: raise exception_class(message, screen, stacktrace)
[2024-08-15T20:31:07.564]: selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
[2024-08-15T20:31:07.564]: (chrome not reachable)
[2024-08-15T20:31:07.564]: (The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
I’ve tried everything, from changing the options, adding the line
self.driver = webdriver.Chrome(service=ChromeDriverManager().install(), options=options)
Which makes my code make infinite loops… I have removed “headless” option because the website behaves in a weird way, and I haven’t figured it out about it. Nothing I did worked at all.