Я создал .exe для кода ниже. Я создал / dist и теперь пытаюсь запустить .exe, но ничего не произошло. Подскажите, пожалуйста, как действовать, или я что-то не так делаю? Можно ли выполнить приведенный ниже код с помощью .exe. Пожалуйста, предложите.
from selenium import webdriver
from time import sleep
import sys
driver = webdriver.Firefox() # To connect to web browser use webdriver imported from selenium
driver.get('https://web.whatsapp.com/')
name = sys.argv[1]
msg = sys.argv[2]
filepath = sys.argv[3]
def whatsapp(name, msg="", filepath=""):
input('Enter anything after scanning QR code')
user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
user.click()
if msg != "":
msg_box = driver.find_element_by_xpath("//*[@id='main']/footer/div[1]/div[2]/div/div[2]")
msg_box.send_keys(msg) # To send message
button = driver.find_element_by_xpath("//*[@id='main']/footer/div[1]/div[3]/button")
button.click() # click send button
if filepath != "":
attachment_box = driver.find_element_by_xpath('//div[@title = "Attach"]')
attachment_box.click() # click attachment icon button
image_box = driver.find_element_by_xpath(
'//input[@accept="image/*,video/mp4,video/3gpp,video/quicktime"]')
image_box.send_keys(filepath) # To send filepath
sleep(3) # use to set delay time of 3 sec. It will first find the image box,
send_button = driver.find_element_by_xpath('//span[@data-testid="send"]')
send_button.click() # click send button
if name != "":
whatsapp(name, msg, filepath) # parameters are passed at run time using sys.argv
if msg != "" and filepath == "":
print("Only message sent successfully")
elif msg == "" and filepath != "":
print("Only attachment sent successfully")
elif msg == "" and filepath == "":
print("Both message and attachment not sent")
else:
print("Both message and attachment sent successfully")
else:
print("name or group name cannot be empty")