question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getAttribute.js file is not loaded when compile selenium program

See original GitHub issue
> python -m nuitka --version
0.6.4
Python: 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)]
Executable: C:\Users\pc\.virtualenvs\sub_-AoDDHP-o\Scripts\python.exe
OS: Windows
Arch: x86_64
  • Installed via pip with virtualenv.
  • HelloWork example work.

Project structure

sub_/
---- main.py
---- child_process.py

main.py

import os
import subprocess
from multiprocessing import Process, Pipe
from child_process import cron_task as child_process

BASE_DIR = os.path.abspath(os.path.dirname(__file__))

if __name__ == "__main__":
    print(BASE_DIR)
    child_conn, boq_pipe = Pipe()
    child = Process(
        target=child_process,
        name='child_process',
        kwargs={
            'main_pipe': boq_pipe,
            'chrome_driver': os.path.join(BASE_DIR, 'chromedriver')
        }
    )
    child.start()
    print("Child process started.")
    while True:  # Waiting Child process messages
        print(child_conn.recv())

child_process.py

import os
import uuid
import time
from selenium import webdriver

def cron_task(main_pipe, chrome_driver):
    while True:
        main_pipe.send("Running %s " % uuid.uuid4().hex)
        driver = webdriver.Chrome(executable_path=chrome_driver)
        driver.get('https://google.com')
        driver.close()
        time.sleep(60)

Error detail When compiling and execute script the follow is raise: image

Fix error

  1. I have go to site-packages\selenium\webdriver\remote of my virtualenv and copy manually getAttribute.js and isDisplayed.js files.
  2. Go to .dist nuitka directory and create the path selenium\webdriver\remote.
  3. Paste inside remote directory create on 2 step the files copy on 1 step.

PD: Thinking that this process nuitka could do itself with --follow-imports options.

Nuitka compilation command: python -m nuitka --standalone --plugin-enable=multiprocessing --follow-imports --recurse-all --show-modules --show-scons --show-progress --mingw64 main.py

Nuitka command output: nuitka_compilation_output.txt

Insert on .txt format (too much lines).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
remcoNLcommented, Apr 26, 2021

So to add the complete command:

python -m nuitka --onefile Main.py --include-package-data selenium --include-data-dir ./templates=./templates ./static=./static --run

2reactions
FeelsBadMan1commented, Sep 17, 2021

Thank u guys a lot. i wasted about 1 week only searching up the error and got some results telling me my selenium installation is corrupted but it actually worked in the uncompiled version so today i included the keyword “nuitka” and found this. The written solutions solved the issue. Thanku guys a lot idk how proud im are about these soultions. i thought there never will be a working solution but i was wrong ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python-No such file or directory getAttribute.js - Stack Overflow
Incase the getAttribute.js file doesn't gets downloaded properly Selenium and webdriver modules may not work properly.
Read more >
No such file or directory getAttribute.js : r/learnprogramming
Trying to make a .exe out of my program using pyinstaller. However, this error appears. I tried reinstalling selenium, but the error ...
Read more >
Top 10 Selenium Exceptions and How To Handle These ...
#2) Unchecked Exception: In case of the unchecked exception, a compiler does not mandate to handle. The compiler ignores during compile time.
Read more >
HTML DOM Element getAttribute() Method - W3Schools
Definition and Usage. The getAttribute() method returns the value of an element's attribute.
Read more >
JavaScript getAttribute() method - javatpoint
If the corresponding attribute does not exist, it will return an empty string or null. It is different from the getAttributeNode() method. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found