0

I am creating a webscraper and the idea is to use Selenium, Robocorp and VSCode altogether.

I understand that Robocorp already has a file YAML that contains de dependencies of the code, but my doubt is, can I simply PIP INSTALL RPA.core.webdriver?

In my code , there is:

from RPA.core.webdriver import cache, download, start

and then:

def set_webdriver(self, browser="Chrome"):
    options = self.set_chrome_options()
    executable_driver_path = cache(browser)
    if not executable_driver_path:
        executable_driver_path = download(browser)
        self.logger.warning("Using downloaded driver: %s" % executable_driver_path)
    else:
        self.logger.warning("Using cached driver: %s" % executable_driver_path)

    self.driver = start("Chrome", executable_path=str(executable_driver_path), options=options)

Since then the error appears. How can I solve this, with conda.yaml?

# For more details on the format and content:
# https://github.com/robocorp/rcc/blob/master/docs/recipes.md#what-is-in-condayaml
# Tip: Adding a link to the release notes of the packages helps maintenance and security.

channels:
  - conda-forge

dependencies:
  - python=3.10.12                    # https://pyreadiness.org/3.10
  - pip=23.2.1                        # https://pip.pypa.io/en/stable/news
  - robocorp-truststore=0.8.0         # https://pypi.org/project/robocorp-truststore/
  - nodejs=16.20.2                    # https://github.com/nodejs/node/blob/main/CHANGELOG.md
  - pip:
    - robotframework-browser==17.5.2  # https://github.com/MarketSquare/robotframework-browser/releases
    - rpaframework==27.7.0            # https://rpaframework.org/releasenotes.html

rccPostInstall:
  - rfbrowser init                    # Initialize Playwright

I tried to use a method that uses a dependency, that I have no idea if it's already in the code.

`ImportError: cannot import name 'cache' from 'RPA.core.webdriver`

UPDATE I managed to install conda into my machine, ran the conda.YAML, created a environment, but I still cannot import this RPA.core. Does it even exists anymore?

2 Answers 2

0

The RPA.core is not meant to be separately used as it is a supporting package for "public" rpaframework packages like the description says in the PyPI

Project description

This package is a set of core functionality and utilities used by RPA Framework. It is not intended to be installed directly, but as a dependency to other projects.

I recommend installing the latest rpaframework==28.6.2 which contains a fix for the latest Chrome webdriver issues.

The cache is not importable from RPA.core.webdriver, but instead of trying to make your code snippet work I ask what you are trying to achieve?

Sign up to request clarification or add additional context in comments.

3 Comments

I'm trying to do a python web scraper that utilizes Selenium and RPAframework... The idea is to input a search phrase, the news category, and the number of months i need to receive the news. Finally, I would store the scraped data into a Excel file. But I'm having this issue not because of these functionalities, but because I was pointed to your code to see it as a 'model'. Therefore I am just trying to get the libraries working first so then I could implement the rest.
Yeah, I understood the web scraper target, but I did not understand the need to modify core functionality.
Mika, neither do I haha, but I thought using CustomSelenium would be better in terms of optimization so I chose to use it. Or ExtendedSelenium would be better? Sorry I'm kinda new to RPA
0

Well, it looks like this is a very old architecture used for Selenium. Now, the Chrome webdriver is automatically downloaded and there is no need to specify the path anymore. My current versions accept the following code:

from selenium.webdriver import ChromeOptions
from selenium import webdriver
class CustomSelenium:
    def set_webdriver(self):
    self._driver = webdriver.Chrome(options=self._options)
    print("WebDriver initialized successfully.")

cs = CustomSelenium()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.