Reputation: 351
I'm building a simple automation app that will use Electron JS for good GUI and then Python Selenium to automate the task.
I've just started when I'm trying to run electron JS app it shows that there is no module named as selenium.
import time
import re
from selenium import webdriver
import webbrowser
import sys
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('https://example.com')
userid = browser.find_element_by_id('user')
time.sleep(1)
userpass = browser.find_element_by_id('password')
time.sleep(1)
userid.send_keys('[email protected]')
time.sleep(1)
userpass.send_keys('#jlasdjf#')
time.sleep(1)
userid.send_keys(Keys.RETURN)
userid.clear()
browser.refresh()
time.sleep(5)
print('Hello from Python!')
sys.stdout.flush()
And the goes my index.js file
-
function some(){
var ps = require("python-shell")
var path = require("path")
var options = {
scriptPath : path.join(__dirname,'../seleniumBro/'),
pythonPath : '/usr/local/bin/python3.8'
}
ps.PythonShell.run('../../seleniumBro/demo.py', options, function (err, results) {
if (err) throw err;
// swal(results[0]);
console.log(results[0])
});
}
When I run the app I get this error in console.
index.js:12 Uncaught Error: ModuleNotFoundError: No module named 'selenium'
at PythonShell.parseError (/Users/rahul/Desktop/justDev/electronBro/hello-world/node_modules/python-shell/index.js:258:21)
at terminateIfNeeded (/Users/rahul/Desktop/justDev/electronBro/hello-world/node_modules/python-shell/index.js:141:32)
at ChildProcess.<anonymous> (/Users/rahul/Desktop/justDev/electronBro/hello-world/node_modules/python-shell/index.js:133:13)
at ChildProcess.emit (events.js:223:5)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
----- Python Traceback -----
File "/Users/rahul/Desktop/justDev/seleniumBro/demo.py", line 3, in <module>
from selenium import webdriver
I'm on MAC OS. And also new to this. Please help.
Upvotes: 1
Views: 480
Reputation: 56
As per my views. You should go with Node.js as said by pguardio that Selenium is available for node too.
Upvotes: 1