I am trying to automate something using a python
script from php
. I have the following codes in php
whereby it is trying to execute the python script
$command = escapeshellcmd('python interaction.py');
$output = shell_exec($command);
I have the interaction.py
python script in the same location. Also the chrome driver
in the same location too.
interaction.py
contains the following codes
from selenium import webdriver # Importing the web driver class from selenium
from selenium.webdriver.common.keys import Keys # This is the import for those keys that is not letter, number etc. Eg: Enter, Tab, Shift etc
driver_location = "chromedriver.exe" # Chrome driver location
driver = webdriver.Chrome(executable_path=driver_location) # Initiating the driver
driver.get("http://secure-retreat-92358.herokuapp.com/") # Opening the web page
But when I trigger the php page, the python is not executing. I believe this could be due to the libraries are not imported correctly. I used pycharm
to run and test that python
script whereby all those libraries are able to import correctly and execute the codes.
Does anyone know what is the issue here? If that is due to those import issue, how can I include those imports successfully into my interaction.py
file while calling from php
?