简体   繁体   中英

python ModuleNotFoundError: No module named 'Common_Methods'

I am trying to follow this example of generating a click on the extension. below is my code

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import pyautogui
import json
import os
from Common_Methods.GenericMethods import *

options = webdriver.ChromeOptions()
options.add_argument("--load-extension=./Edit-This-Cookie")
driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=options)

driver.get("https://google.com")
# get the extension box
extn = pyautogui.locateOnScreen(os.path.join(GenericMethods.get_full_path_to_folder() + "/icon_16x16.png"))
# click on extension 
pyautogui.click(x=extn[0],y=extn[1],clicks=1,interval=0.0,button="left")

I am getting the error

    from Common_Methods.GenericMethods import *
    ModuleNotFoundError: No module named 'Common_Methods'

I tried to check if there is any module by that name in pip, but there are none. I am presently using python version 3.9.0 , I tried switching to 2.7 but the package still seems missing.

EDIT: removing the from Common_Methods.GenericMethods import * gives the following error:-

NameError: name 'GenericMethods' is not defined
from Common_Methods.GenericMethods import *

That seems to be a package specific to thier framework you can simply remove it

extn = pyautogui.locateOnScreen("absolutepathtofile/icon_16x16.png")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM