代码之家  ›  专栏  ›  技术社区  ›  Saul

Python Selenium Select下拉菜单选项

  •  0
  • Saul  · 技术社区  · 7 年前

    Menu and SubMenu Screenshot

    分配按钮的代码是什么:

    HTML code from Google Chrome

    HTML 2-当我悬停在“添加拍卖任务”上时,它似乎会弹出一个称为javascript的东西,但我不知道。

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    from selenium.common.exceptions import TimeoutException
    from selenium.webdriver import ActionChains
    from selenium.webdriver.support.ui import Select
    
    browser = webdriver.Chrome("C:\Program Files\chromedriver_win32/chromedriver.exe")
    
    actions = ActionChains(browser)
    
    #Go to the desired website
    browser.get("http://www.autoims.com/external/index.jsp")
    
    usrname_box = browser.find_element_by_xpath('//*[@id="loginUsername"]')
    pw_box =  browser.find_element_by_xpath('//*[@id="password"]')
    login_button =  browser.find_element_by_xpath('//*[@id="submit"]')
    
    #login process here
    
    wait = WebDriverWait(browser, 10)
    
    for vin in df['VIN']:
        assignments = wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="_img0"]')))
        ActionChains(browser).move_to_element(assignments).perform()
    
        add_assignment = wait.until(EC.visibility_of_element_located((By.XPATH, "  HELP :(  "))) #always fails
        ActionChains(browser).move_to_element(add_assignment).click().perform()
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   yong    7 年前

    对于一些JQuery navbar插件,

    您可以先向下滚动到页面源代码的末尾,然后将鼠标悬停在分配菜单上,同时查看附加的任何新html代码或任何html代码 改变

    它是用脚本写的。