0

I'm working on a web page and I want to interact with it. I believe Selenium is the best option but I have no idea how to use it.

The only step I have taken is

pip install selenium

I'm getting errors like

web driver not defined

The Selenium documentation is difficult to understand. My default browser is Opera.

from selenium import webdriver
driver = webdriver.Opera()
driver.get('https://www.google.co.in/search?client=opera&q=google&sourceid=opera&ie=UTF-8&oe=UTF-8')
AS Mackay
  • 2,831
  • 9
  • 19
  • 25

2 Answers2

0

A driver is required in order for Selenium to know how to interact with the browser - see this section of the documentation.

Oliver.R
  • 1,282
  • 7
  • 17
  • Ok but where to place the webdriver for opera ? –  Jan 23 '20 at 06:10
  • @Naveen It is all written in the docs. just click the link and read the text – luigigi Jan 23 '20 at 06:12
  • More information specifically for the Opera driver can be found on the [Github page](https://github.com/operasoftware/operaprestodriver) and in this [previous StackOverflow question](https://stackoverflow.com/questions/24719270/selenium-webdriver-and-opera-driver) – Oliver.R Jan 23 '20 at 06:32
0

As you have mentioned you already have:

  • pip install selenium

Now, you need to downloaded the latest OperaChromiumDriver from operasoftware / operachromiumdriver and place it any where within your system. Finally, you need to pass the Key executable_path along with the Value referring to the absolute path of the OperaDriver as an argument while initializing the WebDriver and WebBrowser as follows :

from selenium import webdriver

driver = webdriver.Opera(executable_path=r'C:\path\to\operadriver.exe')
driver.get('https://www.google.co.in/search?client=opera&q=google&sourceid=opera&ie=UTF-8&oe=UTF-8')

You can find a relevant discussion in Unable to launch Opera using Python Selenium

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I tired with chrome but the page is not opening i'm getting error like this: ```DevTools listening on ws://127.0.0.1:60400/devtools/browser/12414d7b-91c7-43fa-be4f-399a471969f1``` how to fix this ? And i tired with opera as you said but i'm getting error binary location not found –  Jan 23 '20 at 14:18
  • @Naveen Did you check the relevant discussion I have added as a reference? – undetected Selenium Jan 23 '20 at 14:22