JSON to Python translation Visio UI

Hello i’ve created an automation using VisionUI , now i did take the code whos in ‘json’ and translate it to Python, but on python selenium the ‘clicks’ dont work.
i can run the script on VisionUI and it works but when i translate it to python it cant click the proper buttons.

i was writing my code in python at first but had a simillar problem had stuck on a button whos on double iframe and hidden and couldnt catch the link.

however on vision ui and in json it works , but i wanna make it work in python

here is my json ‘code’

{
  "Name": "downloadzoom",
  "CreationDate": "2024-8-3",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://zoom.us/signin#/login",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "id=email",
      "Value": "[email protected]",
      "Targets": [
        "id=email",
        "name=new-email",
        "xpath=//*[@id="email"]",
        "xpath=//input[@id='email']",
        "xpath=//input",
        "css=#email"
      ],
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "id=password",
      "Value": "Gp0Gg390z@*0",
      "Targets": [
        "id=password",
        "name=password",
        "xpath=//*[@id="password"]",
        "xpath=//input[@id='password']",
        "xpath=//div[2]/div/div/input",
        "css=#password"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=email",
      "Value": "",
      "Targets": [
        "id=email",
        "name=new-email",
        "xpath=//*[@id="email"]",
        "xpath=//input[@id='email']",
        "xpath=//input",
        "css=#email"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=email",
      "Value": "",
      "Targets": [
        "id=email",
        "name=new-email",
        "xpath=//*[@id="email"]",
        "xpath=//input[@id='email']",
        "xpath=//input",
        "css=#email"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=email",
      "Value": "",
      "Targets": [
        "id=email",
        "name=new-email",
        "xpath=//*[@id="email"]",
        "xpath=//input[@id='email']",
        "xpath=//input",
        "css=#email"
      ],
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "id=email",
      "Value": "[email protected]",
      "Targets": [
        "id=email",
        "name=new-email",
        "xpath=//*[@id="email"]",
        "xpath=//input[@id='email']",
        "xpath=//input",
        "css=#email"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=password",
      "Value": "",
      "Targets": [
        "id=password",
        "name=new-password",
        "xpath=//*[@id="password"]",
        "xpath=//input[@id='password']",
        "xpath=//div[2]/div/div/input",
        "css=#password"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=password",
      "Value": "",
      "Targets": [
        "id=password",
        "name=new-password",
        "xpath=//*[@id="password"]",
        "xpath=//input[@id='password']",
        "xpath=//div[2]/div/div/input",
        "css=#password"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=password",
      "Value": "",
      "Targets": [
        "id=password",
        "name=new-password",
        "xpath=//*[@id="password"]",
        "xpath=//input[@id='password']",
        "xpath=//div[2]/div/div/input",
        "css=#password"
      ],
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "id=password",
      "Value": "Qb9V[4:K6",
      "Targets": [
        "id=password",
        "name=password",
        "xpath=//*[@id="password"]",
        "xpath=//input[@id='password']",
        "xpath=//div[2]/div/div/input",
        "css=#password"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id="js_btn_login"]/span",
      "Value": "",
      "Targets": [
        "xpath=//*[@id="js_btn_login"]/span",
        "xpath=//div[4]/button/span",
        "css=#js_btn_login > span"
      ],
      "Description": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "linkText=Recordings",
      "Value": "",
      "Targets": [
        "linkText=Recordings",
        "xpath=//*[@id="personal-nav-list"]/li[9]/a",
        "xpath=//li[9]/a",
        "css=#personal-nav-list > li:nth-child(9) > a"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id="recordingTable"]/div[3]/div/div/div/table/tbody/tr/td[6]/div/div/div/div/button/i",
      "Value": "",
      "Targets": [
        "xpath=//*[@id="recordingTable"]/div[3]/div/div/div/table/tbody/tr/td[6]/div/div/div/div/button/i",
        "xpath=//td[6]/div/div/div/div/button/i",
        "css=#recordingTable > div.zm-table__body-wrapper.is-scrolling-none > div > div.zm-scrollbar__wrap > div > table > tbody > tr > td.zm-table_2_column_12.is-right.cell-wrapper > div > div > div > div > button > i"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id="dropdown_item_dropdown-menu-9406-0"]/span/div",
      "Value": "",
      "Targets": [
        "xpath=//*[@id="dropdown_item_dropdown-menu-9406-0"]/span/div",
        "xpath=//span/div",
        "css=#dropdown_item_dropdown-menu-9406-0 > span > div"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body/div[4]/div/div[3]/span/button/span",
      "Value": "",
      "Targets": [
        "xpath=/html/body/div[4]/div/div[3]/span/button/span",
        "xpath=//div[3]/span/button/span",
        "css=body > div.zm-dialog__wrapper > div > div.zm-dialog__footer > span > button.mr-8.zm-button--primary.zm-button--small.zm-button > span"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "id=headerPic",
      "Value": "",
      "Targets": [
        "id=headerPic",
        "xpath=//*[@id="headerPic"]",
        "xpath=//img[@id='headerPic']",
        "xpath=//ul[4]/li[6]/a/img",
        "css=#headerPic"
      ],
      "Description": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "xpath=//*[@id="btnLogout"]/span",
      "Value": "",
      "Targets": [
        "xpath=//*[@id="btnLogout"]/span",
        "xpath=//a[3]/span",
        "css=#btnLogout > span"
      ],
      "Description": ""
    }
  ]
}

and here is the python code

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import logging

# Configure logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def execute_commands(driver, commands):
    for command in commands:
        logging.info(f"Executing command: {command['Command']} with target: {command['Target']}")
        try:
            if command["Command"] == "open":
                driver.get(command["Target"])
            elif command["Command"] == "click":
                element = WebDriverWait(driver, 20).until(
                    EC.element_to_be_clickable((By.XPATH, command["Target"].split('=')[1]))
                )
                element.click()
            elif command["Command"] == "type":
                element = WebDriverWait(driver, 20).until(
                    EC.presence_of_element_located((By.XPATH, command["Target"].split('=')[1]))
                )
                element.clear()
                element.send_keys(command["Value"])
            elif command["Command"] == "clickAndWait":
                element = WebDriverWait(driver, 20).until(
                    EC.element_to_be_clickable((By.LINK_TEXT, command["Target"].split('=')[1]))
                )
                element.click()
            else:
                logging.error(f"Command {command['Command']} not recognized")
        except Exception as e:
            logging.error(f"Exception occurred while executing command: {command['Command']} with target: {command['Target']}")
            logging.error(str(e))
            driver.save_screenshot(f"screenshot_{command['Command']}_{command['Target'].replace('=', '_').replace('/', '_')}.png")
            raise

if __name__ == "__main__":
    commands = [
        {"Command": "open", "Target": "https://zoom.us/signin#/login", "Value": "", "Description": ""},
        {"Command": "type", "Target": "id=email", "Value": "[email protected]", "Targets": ["id=email", "name=new-email", "xpath=//*[@id="email"]", "xpath=//input[@id='email']", "xpath=//input", "css=#email"], "Description": ""},
        {"Command": "type", "Target": "id=password", "Value": "Gp0Gg390z@*0", "Targets": ["id=password", "name=password", "xpath=//*[@id="password"]", "xpath=//input[@id='password']", "xpath=//div[2]/div/div/input", "css=#password"], "Description": ""},
        {"Command": "click", "Target": "id=onetrust-accept-btn-handler", "Value": "", "Targets": ["id=onetrust-accept-btn-handler", "xpath=//*[@id="onetrust-accept-btn-handler"]", "xpath=//button[@id='onetrust-accept-btn-handler']", "xpath=//div[2]/div/div/button[2]", "css=#onetrust-accept-btn-handler"], "Description": ""},
        {"Command": "open", "Target": "https://zoom.us/signin#/login", "Value": "", "Description": ""},
        {"Command": "click", "Target": "id=email", "Value": "", "Targets": ["id=email", "name=new-email", "xpath=//*[@id="email"]", "xpath=//input[@id='email']", "xpath=//input", "css=#email"], "Description": ""},
        {"Command": "type", "Target": "id=email", "Value": "[email protected]", "Targets": ["id=email", "name=new-email", "xpath=//*[@id="email"]", "xpath=//input[@id='email']", "xpath=//input", "css=#email"], "Description": ""},
        {"Command": "click", "Target": "xpath=//*[@id="app"]/div/div[2]/div/div/form/div[2]/div/div/label", "Value": "", "Targets": ["xpath=//*[@id="app"]/div/div[2]/div/div/form/div[2]/div/div/label", "xpath=//div[2]/div/div/label", "css=#app > div > div.layout-main > div > div:nth-child(2) > form > div.zm-form-item.zm-form-password.is-no-asterisk > div > div > label"], "Description": ""},
        {"Command": "click", "Target": "id=password", "Value": "", "Targets": ["id=password", "name=new-password", "xpath=//*[@id="password"]", "xpath=//input[@id='password']", "xpath=//div[2]/div/div/input", "css=#password"], "Description": ""},
        {"Command": "type", "Target": "id=password", "Value": "Qb9V[4:K6", "Targets": ["id=password", "name=password", "xpath=//*[@id="password"]", "xpath=//input[@id='password']", "xpath=//div[2]/div/div/input", "css=#password"], "Description": ""},
        {"Command": "click", "Target": "xpath=//*[@id="js_btn_login"]/span", "Value": "", "Targets": ["xpath=//*[@id="js_btn_login"]/span", "xpath=//div[4]/button/span", "css=#js_btn_login > span"], "Description": ""},
        {"Command": "clickAndWait", "Target": "linkText=Recordings", "Value": "", "Targets": ["linkText=Recordings", "xpath=//*[@id="personal-nav-list"]/li[9]/a", "xpath=//li[9]/a", "css=#personal-nav-list > li:nth-child(9) > a"], "Description": ""},
        {"Command": "click", "Target": "xpath=//*[@id="recordingTable"]/div[3]/div/div/div/table/tbody/tr/td[6]/div/div/div/div/button/i", "Value": "", "Targets": ["xpath=//*[@id="recordingTable"]/div[3]/div/div/div/table/tbody/tr/td[6]/div/div/div/div/button/i", "xpath=//td[6]/div/div/div/div/button/i", "css=#recordingTable > div.zm-table__body-wrapper.is-scrolling-none > div > div.zm-scrollbar__wrap > div > table > tbody > tr > td.zm-table_2_column_12.is-right.cell-wrapper > div > div > div > div > button > i"], "Description": ""},
        {"Command": "click", "Target": "xpath=//*[@id="dropdown_item_dropdown-menu-8685-0"]/span/div", "Value": "", "Targets": ["xpath=//*[@id="dropdown_item_dropdown-menu-8685-0"]/span/div", "xpath=//span/div", "css=#dropdown_item_dropdown-menu-8685-0 > span > div"], "Description": ""},
        {"Command": "click", "Target": "xpath=/html/body/div[4]/div/div[3]/span/button/span", "Value": "", "Targets": ["xpath=/html/body/div[4]/div/div[3]/span/button/span", "xpath=//div[3]/span/button/span", "css=body > div.zm-dialog__wrapper > div > div.zm-dialog__footer > span > button.mr-8.zm-button--primary.zm-button--small.zm-button > span"], "Description": ""},
        {"Command": "click", "Target": "id=headerPic", "Value": "", "Targets": ["id=headerPic", "xpath=//*[@id="headerPic"]", "xpath=//img[@id='headerPic']", "xpath=//ul[4]/li[6]/a/img", "css=#headerPic"], "Description": ""},
        {"Command": "clickAndWait", "Target": "xpath=//*[@id="btnLogout"]/span", "Value": "", "Targets": ["xpath=//*[@id="btnLogout"]/span", "xpath=//a[3]/span", "css=#btnLogout > span"], "Description": ""}
    ]

    # Set Chrome options
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--disable-search-engine-choice-screen")

    # Create WebDriver instance with options
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
    driver.implicitly_wait(10)

    try:
        # Execute commands
        execute_commands(driver, commands)
    finally:
        driver.quit()

New contributor

Greg Fotopoulos is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật