2
votes

I'm trying to run a python script from PHP(Using Laravel) that uses Selenium -> Firefox.

It's now running the latest firefox, selenium 3.11.0 and geckodriver 0.20.0

When i run the python script test.py from PHP:

    $scrape = 'python '.base_path().'Description\test.py 2>&1';
    $output = shell_exec($scrape);
    echo($output);

Where the test.py is:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

options = Options()
print("Created Options")
options.add_argument("--headless")
print("Added options")
binary = FirefoxBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe")
fp = webdriver.FirefoxProfile()
print("Binary set up")
driver = webdriver.Firefox(firefox_binary=binary, firefox_profile=fp, firefox_options = options)
driver.get("http://www.google.com")
print("Going to URL")
driver.quit()
print("Quit")

I gave permissions to the entire lib directory for python, geckdodriver and firefox, to have full-control under IIS_IUSRS (Using Windows).

Log of geckodriver:

1523551010316   geckodriver INFO    geckodriver 0.19.0
1523551010337   geckodriver INFO    Listening on 127.0.0.1:55452
1523552906639   geckodriver INFO    geckodriver 0.19.0
1523552906660   geckodriver INFO    Listening on 127.0.0.1:64886
1523552982150   geckodriver INFO    geckodriver 0.19.0
1523552982157   geckodriver INFO    Listening on 127.0.0.1:65274
1523552996397   geckodriver INFO    geckodriver 0.19.0
1523552996403   geckodriver INFO    Listening on 127.0.0.1:65361
1523553042485   geckodriver INFO    geckodriver 0.19.0
1523553042491   geckodriver INFO    Listening on 127.0.0.1:49225
1523553453916   geckodriver INFO    geckodriver 0.19.0
1523553453924   geckodriver INFO    Listening on 127.0.0.1:51324
1523553557325   geckodriver INFO    geckodriver 0.19.0
1523553557332   geckodriver INFO    Listening on 127.0.0.1:51851
1523553572336   geckodriver INFO    geckodriver 0.19.0
1523553572343   geckodriver INFO    Listening on 127.0.0.1:51943
1523553584227   geckodriver INFO    geckodriver 0.19.0
1523553584236   geckodriver INFO    Listening on 127.0.0.1:52020
1523553969221   geckodriver INFO    geckodriver 0.19.0
1523553969254   geckodriver INFO    Listening on 127.0.0.1:53947
1523554425807   geckodriver INFO    geckodriver 0.19.0
1523554425830   geckodriver INFO    Listening on 127.0.0.1:56253
1523554461095   geckodriver INFO    geckodriver 0.19.0
1523554461102   geckodriver INFO    Listening on 127.0.0.1:56446
1523554524912   geckodriver INFO    geckodriver 0.19.0
1523554524919   geckodriver INFO    Listening on 127.0.0.1:56788
1523554661450   geckodriver INFO    geckodriver 0.19.0
1523554661457   geckodriver INFO    Listening on 127.0.0.1:57478
1523554945239   geckodriver INFO    geckodriver 0.19.0
1523554945245   geckodriver INFO    Listening on 127.0.0.1:58934
1523555132097   geckodriver INFO    geckodriver 0.19.0
1523555132104   geckodriver INFO    Listening on 127.0.0.1:59859
1523555833096   geckodriver INFO    geckodriver 0.19.0
1523555833171   geckodriver INFO    Listening on 127.0.0.1:63326
1523556541828   geckodriver INFO    geckodriver 0.19.0
1523556541849   geckodriver INFO    Listening on 127.0.0.1:50425
1523557052268   geckodriver INFO    geckodriver 0.19.0
1523557052288   geckodriver INFO    Listening on 127.0.0.1:53022
1523557865989   geckodriver INFO    geckodriver 0.19.0
1523557865996   geckodriver INFO    Listening on 127.0.0.1:57094
1523558364753   geckodriver INFO    geckodriver 0.19.0
1523558364761   geckodriver INFO    Listening on 127.0.0.1:59596
1523558692756   geckodriver INFO    geckodriver 0.19.0
1523558692763   geckodriver INFO    Listening on 127.0.0.1:61265
1523559379217   geckodriver INFO    geckodriver 0.19.0
1523559379240   geckodriver INFO    Listening on 127.0.0.1:64505
1523559433741   geckodriver INFO    geckodriver 0.19.0
1523559433763   geckodriver INFO    Listening on 127.0.0.1:64792
1523559454014   geckodriver INFO    geckodriver 0.19.0
1523559454021   geckodriver INFO    Listening on 127.0.0.1:64913
1523559499598   geckodriver INFO    geckodriver 0.19.0
1523559499605   geckodriver INFO    Listening on 127.0.0.1:65159
1523559825949   geckodriver INFO    geckodriver 0.19.0
1523559825956   geckodriver INFO    Listening on 127.0.0.1:50459
1523559827139   geckodriver INFO    geckodriver 0.19.0
1523559827146   geckodriver INFO    Listening on 127.0.0.1:50470
1523560435473   geckodriver INFO    geckodriver 0.19.0
1523560435531   geckodriver INFO    Listening on 127.0.0.1:53559
1523562230663   geckodriver INFO    geckodriver 0.19.0
1523562230687   geckodriver INFO    Listening on 127.0.0.1:62289
1523564088330   geckodriver INFO    geckodriver 0.19.0
1523564088338   geckodriver INFO    Listening on 127.0.0.1:54981
1523564554561   geckodriver INFO    geckodriver 0.19.0
1523564554582   geckodriver INFO    Listening on 127.0.0.1:57277
1523564576099   geckodriver INFO    geckodriver 0.19.0
1523564576106   geckodriver INFO    Listening on 127.0.0.1:57397
1523564596509   geckodriver INFO    geckodriver 0.19.0
1523564596517   geckodriver INFO    Listening on 127.0.0.1:57517
1523566668455   geckodriver INFO    geckodriver 0.19.0
1523566668462   geckodriver INFO    Listening on 127.0.0.1:51277
1523566841445   geckodriver INFO    geckodriver 0.19.0
1523566841453   geckodriver INFO    Listening on 127.0.0.1:52131
1523567215532   geckodriver INFO    geckodriver 0.19.0
1523567215540   geckodriver INFO    Listening on 127.0.0.1:53967
1523567239768   geckodriver INFO    geckodriver 0.19.0
1523567239776   geckodriver INFO    Listening on 127.0.0.1:54103
1523567265282   geckodriver INFO    geckodriver 0.19.0
1523567265288   geckodriver INFO    Listening on 127.0.0.1:54242
1523567277430   geckodriver INFO    geckodriver 0.19.0
1523567277438   geckodriver INFO    Listening on 127.0.0.1:54321
1523567285360   geckodriver INFO    geckodriver 0.19.0
1523567285367   geckodriver INFO    Listening on 127.0.0.1:54375
1523567562191   geckodriver INFO    geckodriver 0.19.0
1523567562199   geckodriver INFO    Listening on 127.0.0.1:55752
1523568013582   geckodriver INFO    geckodriver 0.19.0
1523568013603   geckodriver INFO    Listening on 127.0.0.1:58035
1523568126114   geckodriver INFO    geckodriver 0.19.0
1523568126121   geckodriver INFO    Listening on 127.0.0.1:58597
1523568204080   geckodriver INFO    geckodriver 0.19.0
1523568204089   geckodriver INFO    Listening on 127.0.0.1:58995
1523568236866   geckodriver INFO    geckodriver 0.19.0
1523568236873   geckodriver INFO    Listening on 127.0.0.1:59169
1523568365663   geckodriver INFO    geckodriver 0.19.0
1523568365670   geckodriver INFO    Listening on 127.0.0.1:59651
1523568583373   geckodriver INFO    geckodriver 0.19.0
1523568583380   geckodriver INFO    Listening on 127.0.0.1:60709
1523568984663   geckodriver INFO    geckodriver 0.19.0
1523568984683   geckodriver INFO    Listening on 127.0.0.1:62636
1523569163782   geckodriver INFO    geckodriver 0.19.0
1523569163804   geckodriver INFO    Listening on 127.0.0.1:63502
1523579734024   geckodriver INFO    geckodriver 0.19.0
1523579734046   geckodriver INFO    Listening on 127.0.0.1:49377
1523581385149   geckodriver INFO    geckodriver 0.19.0
1523581385171   geckodriver INFO    Listening on 127.0.0.1:57493
1523581448830   geckodriver INFO    geckodriver 0.19.0
1523581448845   geckodriver INFO    Listening on 127.0.0.1:57821
1523607057941   geckodriver INFO    geckodriver 0.19.0
1523607058145   geckodriver INFO    Listening on 127.0.0.1:50889
1523607183263   geckodriver INFO    geckodriver 0.19.0
1523607183306   geckodriver INFO    Listening on 127.0.0.1:51099
1523607240431   geckodriver INFO    geckodriver 0.19.0
1523607240511   geckodriver INFO    Listening on 127.0.0.1:51195
1523623712258   geckodriver INFO    geckodriver 0.19.0
1523623712386   geckodriver INFO    Listening on 127.0.0.1:49413
1523624414430   geckodriver INFO    geckodriver 0.19.0
1523624414437   geckodriver INFO    Listening on 127.0.0.1:49491
1523624471867   geckodriver INFO    geckodriver 0.19.0
1523624471873   geckodriver INFO    Listening on 127.0.0.1:49514
1523624716169   geckodriver INFO    geckodriver 0.19.0
1523624716175   geckodriver INFO    Listening on 127.0.0.1:49544
1523624783033   geckodriver INFO    geckodriver 0.19.0
1523624783040   geckodriver INFO    Listening on 127.0.0.1:49566
1523625431597   geckodriver INFO    geckodriver 0.19.0
1523625431603   geckodriver INFO    Listening on 127.0.0.1:49616
1523625702932   geckodriver INFO    geckodriver 0.19.0
1523625702939   geckodriver INFO    Listening on 127.0.0.1:49644
1523641970187   geckodriver INFO    geckodriver 0.19.0
1523641970231   geckodriver INFO    Listening on 127.0.0.1:50576
1523642534699   geckodriver INFO    geckodriver 0.19.0
1523642534706   geckodriver INFO    Listening on 127.0.0.1:50625
1523642573251   geckodriver INFO    geckodriver 0.19.0
1523642573257   geckodriver INFO    Listening on 127.0.0.1:50647
1523642715989   geckodriver INFO    geckodriver 0.19.0
1523642715996   geckodriver INFO    Listening on 127.0.0.1:50672
1523643125879   geckodriver INFO    geckodriver 0.19.0
1523643125885   geckodriver INFO    Listening on 127.0.0.1:50705
1523643319804   geckodriver INFO    geckodriver 0.19.0
1523643319810   geckodriver INFO    Listening on 127.0.0.1:50741
1523645004597   geckodriver INFO    geckodriver 0.19.0
1523645004604   geckodriver INFO    Listening on 127.0.0.1:50822
1523645077355   geckodriver INFO    geckodriver 0.19.0
1523645077361   geckodriver INFO    Listening on 127.0.0.1:50844
1523645468905   geckodriver INFO    geckodriver 0.19.0
1523645468912   geckodriver INFO    Listening on 127.0.0.1:50887
1523645536572   geckodriver INFO    geckodriver 0.19.0
1523645536579   geckodriver INFO    Listening on 127.0.0.1:50911
1523645646052   geckodriver INFO    geckodriver 0.19.0
1523645646060   geckodriver INFO    Listening on 127.0.0.1:50934
1523646298145   geckodriver INFO    geckodriver 0.19.0
1523646298151   geckodriver INFO    Listening on 127.0.0.1:50983
1523646904316   geckodriver INFO    geckodriver 0.19.0
1523646904323   geckodriver INFO    Listening on 127.0.0.1:51024
1523647702202   geckodriver INFO    geckodriver 0.19.0
1523647702209   geckodriver INFO    Listening on 127.0.0.1:51127
1523647800626   geckodriver INFO    geckodriver 0.19.0
1523647800633   geckodriver INFO    Listening on 127.0.0.1:51149
1523647849026   geckodriver INFO    geckodriver 0.19.0
1523647849032   geckodriver INFO    Listening on 127.0.0.1:51170
1523647970017   geckodriver INFO    geckodriver 0.19.0
1523647970024   geckodriver INFO    Listening on 127.0.0.1:51205
1523647982449   geckodriver INFO    geckodriver 0.19.0
1523647982456   geckodriver INFO    Listening on 127.0.0.1:51225
1523648024245   geckodriver INFO    geckodriver 0.19.0
1523648024251   geckodriver INFO    Listening on 127.0.0.1:51246
1523648280882   geckodriver INFO    geckodriver 0.19.0
1523648280889   geckodriver INFO    Listening on 127.0.0.1:51275
1523648711661   geckodriver INFO    geckodriver 0.19.0
1523648711710   geckodriver INFO    Listening on 127.0.0.1:51304
1523648876955   geckodriver INFO    geckodriver 0.19.0
1523648876962   geckodriver INFO    Listening on 127.0.0.1:51342
1523648981745   geckodriver INFO    geckodriver 0.19.0
1523648981752   geckodriver INFO    Listening on 127.0.0.1:51364
1523649029576   geckodriver INFO    geckodriver 0.19.0
1523649029582   geckodriver INFO    Listening on 127.0.0.1:51383
1523650025386   geckodriver INFO    geckodriver 0.19.0
1523650025392   geckodriver INFO    Listening on 127.0.0.1:51443
1523650231426   geckodriver INFO    geckodriver 0.19.0
1523650231447   geckodriver INFO    Listening on 127.0.0.1:51512
1523650784379   geckodriver INFO    geckodriver 0.19.0
1523650784400   geckodriver INFO    Listening on 127.0.0.1:51676
1523651138455   geckodriver INFO    geckodriver 0.20.1
1523651138478   geckodriver INFO    Listening on 127.0.0.1:51722
1523651421970   geckodriver INFO    geckodriver 0.20.1
1523651421979   geckodriver INFO    Listening on 127.0.0.1:51816
1523651539385   geckodriver INFO    geckodriver 0.20.1
1523651539393   geckodriver INFO    Listening on 127.0.0.1:51845
1523651563942   geckodriver INFO    geckodriver 0.20.1
1523651563953   geckodriver INFO    Listening on 127.0.0.1:51867
1523651617176   geckodriver INFO    geckodriver 0.20.1
1523651617184   geckodriver INFO    Listening on 127.0.0.1:51898
1523651955634   geckodriver INFO    geckodriver 0.20.1
1523651955642   geckodriver INFO    Listening on 127.0.0.1:51933
1523651972841   geckodriver INFO    geckodriver 0.20.1
1523651972849   geckodriver INFO    Listening on 127.0.0.1:51954
1523652422260   geckodriver INFO    geckodriver 0.20.1
1523652422269   geckodriver INFO    Listening on 127.0.0.1:51990
1523652679606   geckodriver INFO    geckodriver 0.20.0
1523652679631   geckodriver INFO    Listening on 127.0.0.1:52034
1523653035745   geckodriver INFO    geckodriver 0.20.0
1523653035754   geckodriver INFO    Listening on 127.0.0.1:52112
1523653444434   geckodriver INFO    geckodriver 0.20.0
1523653444442   geckodriver INFO    Listening on 127.0.0.1:52201
1523653445096   geckodriver INFO    geckodriver 0.20.0
1523653445104   geckodriver INFO    Listening on 127.0.0.1:52206
1523653445765   geckodriver INFO    geckodriver 0.20.0
1523653445773   geckodriver INFO    Listening on 127.0.0.1:52217
1523653447197   geckodriver INFO    geckodriver 0.20.0
1523653447205   geckodriver INFO    Listening on 127.0.0.1:52229
1523653447399   geckodriver INFO    geckodriver 0.20.0
1523653447408   geckodriver INFO    Listening on 127.0.0.1:52231
1523653455732   geckodriver INFO    geckodriver 0.20.0
1523653455740   geckodriver INFO    Listening on 127.0.0.1:52257
1523653695320   geckodriver INFO    geckodriver 0.20.0
1523653695328   geckodriver INFO    Listening on 127.0.0.1:52287
1523656451072   geckodriver INFO    geckodriver 0.20.0
1523656451081   geckodriver INFO    Listening on 127.0.0.1:52419
1523702123572   geckodriver INFO    geckodriver 0.20.0
1523702123607   geckodriver INFO    Listening on 127.0.0.1:54308
1523702293855   geckodriver INFO    geckodriver 0.20.0
1523702293864   geckodriver INFO    Listening on 127.0.0.1:54335

Error produced:

File "C:\inetpub\wwwroot\jobDescription\test.py", line 13, in driver = webdriver.Firefox(firefox_options = options,firefox_binary=binary) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 162, in init keep_alive=True) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in init self.start_session(desired_capabilities, browser_profile) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute self.error_handler.check_response(response) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: permission denied

1

1 Answers

0
votes

OK so this is going to be a list of all answers to every error i have gotten, which may help future people.

WebDriverException: Message: Unable to find a matching set of capabilities

This error seems to run, when one of your programs is out of date. IE: Selenium / Firefox/ Geckodriver. I recommend updating them all / check if they're compatible which each other Some versions are not compatible with each other).

WebDriverException: Message: permission denied

If your using IIS, you will need to change your application pool identity.

IIS->site that need access-Authentication settings -> anonymous authentication->edit->select application pool identity (instead of IUSER).

WebDriverException: Message: Process unexpectedly closed with status: 0

Update geckodriver

WebDriverException: Message: connection reset

Try using the Nightly version of Firefox and update the binary path to it.