1

how to make selenium window not open? i don't want see open window, but i need use selenium, because i need get info about headers, who load very slow. Code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time 
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

PATH =".\msedgedriver.exe"
driver = webdriver.Edge(PATH)

driver.get("https://www.verivox.de/stromvergleich/vergleich/#/?plz=10555&persons=on&usage=3500&bonus=OnlyCompliant&profile=H0&product=electricity&source=1&q=WzYsMCwxLDEsMSwxLDEsMiwyMCwwLDEsNzQxMTIyLCI3MTA4NSIsMSwyNDAsMjQwLDM1MDAsMCwwLDAsOTk5LC0xLC0xLC0xLDAsMCwiVG90YWxDb3N0cyIsIkFzY2VuZGluZyIsIk5vbmUiLDM4LCJBbm51YWxDb3N0VmlldyIsMF0%3D&partnerid=1")


allheader=WebDriverWait(driver,20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR,"li[class='result-item'] .result-name-area>.result-name")))
for header in allheader:
     print("Header: " + header.text)

i was try use phantonJS() but hten my code not working and getting

UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
  warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '

i was trying use xvfbwrapper too, but getting error

Traceback (most recent call last):
  File "skriptas.py", line 8, in <module>
    from xvfbwrapper import Xvfb
  File "C:\Users\andri\AppData\Roaming\Python\Python38\site-packages\xvfbwrapper.py", line 15, in <module>
    import fcntl
ModuleNotFoundError: No module named 'fcntl'

Any idea how to do it? Thank you for help.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Kalakutas
  • 124
  • 2
  • 15

1 Answers1

0

This message...

UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
  warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '

...wasn't an error as such but the deprecation warning of support.


Solution

Use the following line of code to supress the error:

import warnings

warnings.filterwarnings("ignore")
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • but not workink my code than Traceback (most recent call last): ```File "skriptas.py", line 17, in allheader=WebDriverWait(driver,20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR,"li[class='result-item'] .result-name-area>.result-name"))) File "C:\Program Files\Python38\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:``` – Kalakutas Nov 20 '20 at 09:22
  • @Kalakutas Your question heading was _...How to make browser window not open..._ and a concern with the `deprecation warning`. Hence was my answer. Of coarse the answer doesn't address the finding of elements. You may need to raise a new question for your new requirement. – undetected Selenium Nov 20 '20 at 09:47
  • ohh, but your code just ignore first warning about Selenium support for ```PhantomJS has been deprecated``` its not solve my problem here. – Kalakutas Nov 20 '20 at 10:09
  • @Kalakutas True, please reread your question heading _...How to make browser window not open..._ which points to the warning but not the element finding part. – undetected Selenium Nov 20 '20 at 10:14
  • 1
    fine, you win :/ – Kalakutas Nov 20 '20 at 10:16
  • @Kalakutas The real winner is you, an integral part of this StackOverflow user community. – undetected Selenium Nov 20 '20 at 10:20