simonradier / node-red-contrib-simple-webdriver

SimpleWebdriver nodes for Node-RED initially based on node-red-contrib-selenium-wd2
Apache License 2.0
14 stars 7 forks source link

make it work on pi 0 w2 headless #59

Open corke opened 2 months ago

corke commented 2 months ago

Hello,

I m trying to use your node on my pi 0 w2 headless, but unfortunally it don't want to open the browser :

image

Any idea what I could do ?

Thank you

simonradier commented 2 months ago

Hi @corke

A stupid question, have you installed Chromium on your raspberry? Are you able to make Selenium or a similar tooling work on it?

Best regards,

corke commented 2 months ago

Hello @simonradier

I made a complete new installation of my pi zero with selenium, I test it manually with this script :

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

chromedriver_path = '/usr/bin/chromedriver'

options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')

service = Service(chromedriver_path)

driver = webdriver.Chrome(service=service, options=options)

url = "https://google.fr"

driver.get(url)
print(driver.title)
driver.close()

and it's work, then I wanted to try with node red but still the same problem. Before to start with nodered I start "chromedriver" but unfortuanly not working. My test :

image image

thank you Best regards

simonradier commented 2 months ago

Can you share your node-red terminal logs please.

corke commented 2 months ago

Hello @simonradier I don't know how but it's seems it's work now. But on my pi zero it's really really slow, I m not sure I could use it but seems it's working fine.

Edit : It's work when I use Chrome browser but not chromium browser, there is logs when I try with chromium

23 Apr 01:54:42 - [info] [open browser:4c14fdf9920938bb] http://localhost:9515 is reacheable by Node-red
[TRACE][2024-04-23T00:54:55.121Z][Object.call|api.js:34] Calling : POST http://localhost:9515/session
[DEBUG][2024-04-23T00:54:55.188Z][Object.call|api.js:37] :
WebDriverRequest {
  data: { capabilities: { alwaysMatch: [Object] } },
  requestOptions: {
    headers: {
      'Content-Type': 'application/json;charset=utf-8',
      'Cache-Control': 'no-cache',
      'Content-Length': 145
    },
    method: 'POST',
    timeout: 10000
  },
  path: 'session'
}
[DEBUG][2024-04-23T00:54:55.208Z][Object.call|api.js:38] :
HttpResponse {
  statusCode: 500,
  statusMessage: 'Internal Server Error',
  body: {
    value: {
      error: 'session not created',
      message: 'session not created: No matching capabilities found',
      stacktrace: '#0 0x0055581bc3e4 <unknown>\n' +
        '#1 0x005557ef1ac8 <unknown>\n' +
        '#2 0x005557f5bad4 <unknown>\n' +
        '#3 0x005557f5b2a4 <unknown>\n' +
        '#4 0x005557f5c9a4 <unknown>\n' +
        '#5 0x005557f28d74 <unknown>\n' +
        '#6 0x005557f29760 <unknown>\n' +
        '#7 0x005558186a74 <unknown>\n' +
        '#8 0x005558189e04 <unknown>\n' +
        '#9 0x005558176d7c <unknown>\n' +
        '#10 0x00555818a714 <unknown>\n' +
        '#11 0x00555815f0e0 <unknown>\n' +
        '#12 0x0055581abbc4 <unknown>\n' +
        '#13 0x0055581abdc0 <unknown>\n' +
        '#14 0x0055581bb5b4 <unknown>\n' +
        '#15 0x007fabac0648 start_thread\n' +
        '#16 0x007fab5e801c <unknown>\n'
    }
  },
  url: 'http://localhost:9515/session'
}
[ERROR][2024-04-23T00:54:55.217Z][Object.call|api.js:40] :
{
  value: {
    error: 'session not created',
    message: 'session not created: No matching capabilities found',
    stacktrace: '#0 0x0055581bc3e4 <unknown>\n' +
      '#1 0x005557ef1ac8 <unknown>\n' +
      '#2 0x005557f5bad4 <unknown>\n' +
      '#3 0x005557f5b2a4 <unknown>\n' +
      '#4 0x005557f5c9a4 <unknown>\n' +
      '#5 0x005557f28d74 <unknown>\n' +
      '#6 0x005557f29760 <unknown>\n' +
      '#7 0x005558186a74 <unknown>\n' +
      '#8 0x005558189e04 <unknown>\n' +
      '#9 0x005558176d7c <unknown>\n' +
      '#10 0x00555818a714 <unknown>\n' +
      '#11 0x00555815f0e0 <unknown>\n' +
      '#12 0x0055581abbc4 <unknown>\n' +
      '#13 0x0055581abdc0 <unknown>\n' +
      '#14 0x0055581bb5b4 <unknown>\n' +
      '#15 0x007fabac0648 start_thread\n' +
      '#16 0x007fab5e801c <unknown>\n'
  }
}
23 Apr 01:54:55 - [error] [open browser:4c14fdf9920938bb] Can't open an instance of chromium
23 Apr 01:54:55 - [error] [open browser:4c14fdf9920938bb] WebDriverResponseError: session not created : session not created: No matching capabilities found
    at Object.call (/home/corke/.node-red/node_modules/@critik/simple-webdriver/dist/api.js:41:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async WebDriver.start (/home/corke/.node-red/node_modules/@critik/simple-webdriver/dist/webdriver.js:400:22)
    at async NodeOpenBrowserConstructor._inputCallback (/home/corke/.node-red/node_modules/node-red-contrib-simple-webdriver/dist/nodes/open-browser.js:47:27)
simonradier commented 2 months ago

Thanks for the logs. I think you've found the answer by yourself! Chrome & Chromium are not the same browser. It should explain why the library was not able to find the capability (browser type). Raspberry pi 0 is quite slow, running a browser it with a good performance level may be complicated.

corke commented 2 months ago

Hello @simonradier, yes I wont be able to make it on my pi zero. otherwise do you have any idea how I can make it on chromium instead chrome ? It's means chromium is not installed on my system ?

Thank you

simonradier commented 2 months ago

Have you tried with both Chrome & Chromium? I see in your screenshot that you configured Chromium. image They provide the same set of features, Chromium just get rid of the strong integration with google services.