6
I want to run the following script in Python by a web site on the server:
#!/Python34/python
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("C:\wamp64\www\desenvol\index.html")
elem1 = driver.find_element_by_link_text("call another page")
elem1.click()
Apache is well configured and I used the page with the web site contains the following in php:
<!doctype html>
<html>
<head>
<title>Light Controller</title>
</head>
<?php
if (isset($_POST['LightON']))
{
echo exec('python hello.py');
echo("on");
}
if (isset($_POST['LightOFF']))
{
shell_exec("sudo python /var/www/lightsoff.py");
echo("Off");
}
?>
<form method="post">
<button name="LightON">Light ON</button>
<button name="LightOFF">Light OFF</button><br><br>
</form>
</html>
What should I do?
Heitor, I didn’t understand a thing, the excerpt driver.find_element_by_link_text looks for a link whose text is "call Another page" but this text does not exist in html. Tell me something, what you want is to fire the button using the python code?
– rodrigorf
What’s the problem? What should I do is very subjective. Looking only at the code I imagine the script
hello.py
is not running (probably because it is not in the same directory).– Juven_v