0
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os

Game_Pin = input('Enter your PIN: ')
NickNAME = input('Enter your nickname: ')

def Enter_Press():
    browser.find_element_by_name("Enter").click()


def Kahoot_Spammer(Game_Pin, NickNAME):
    chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
    browser = webdriver.Chrome(chromedriver)
    browser.get('https://kahoot.it/')

    game_pin = browser.find_element_by_id("Game PIN")
    Name = browser.find_element_by_id("Nickname")

    game_pin.send_keys(Game_Pin)
    Enter_Press()
    Name.send_keys(NickNAME)
    Enter_Press()




Kahoot_Spammer(Game_Pin, NickNAME)

Wondering what I have done wrong in the code above. The file I have put into the path and have ran the

icacls "pathtochromedriver" /grant Users:F

command through the command prompt but it still didn't fix the problem. I have been stuck on this problem for quite some while now.

    Traceback (most recent call last):
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
    stdin=PIPE)
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
PermissionError: [WinError 5] Access is denied

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\KahootSpammer.py", line 28, in <module>
    Kahoot_Spammer(Game_Pin, NickNAME)
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\KahootSpammer.py", line 13, in Kahoot_Spammer
    chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
    self.service.start()
  File "C:\Users\ovvip\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver_win32' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Any ideas on how to fix this? Every time I ask this question I usually end up with a answer that will fix one thing but then another problem arises.

2 Answers2

0

Try using webdriver.Chrome(executable_path=r"C:\WebDriver\bin\chromedriver_win32")

If that doesn't solves the problem than I think there might be an issue with the version of chrome driver you are using download chromedriver from this path

Chromedriver Download Link

and paste it in the directory

and test it for this code it should run smooth without any error

from selenium import webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(executable_path=r"C:\WebDriver\bin\chromedriver.exe")
for j in range(2,8): 
    for i in range(2,8):
        driver.get('https://www.olx.com.pk/lahore/apple/q-iphone-6s/?search%5Bfilter_float_price%3Afrom%5D=40000&search%5Bfilter_float_price%3Ato%5D=55000')
        str1 = '//*[@id="offers_table"]/tbody/tr['
        str2 = ']/td/table/tbody/tr[1]/td[2]/h3/a/span'
        str3 = str1 + str(i) + str2
        a = driver.find_element_by_xpath(str3).text
        print a

Comment below if you face any issue

Usama Jamil
  • 68
  • 10
0

for one thing:

chromedriver = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
browser = webdriver.Chrome(chromedriver)

^^ Here you create a webdriver.Chrome instance named chromedriver. Then on the next line, you attempt to create another webdriver.Chrome instance... but this time passing the existing instance to it? Not sure why you are attempting to create multiple instances of it at all, but that code is definitely not going to work. Just create a single instance of webdriver.Chrome and use it:

browser = webdriver.Chrome(r'C:\WebDriver\bin\chromedriver_win32')
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143