python
  • selenium
  • button
  • submit
  • 2016-12-04 122 views 0 likes 
    0

    我很努力想辦法點擊下面類中的提交按鈕。它不包含ID,名稱或任何非動態生成的易識別方法。任何幫助表示讚賞。Selenium,點擊提交按鈕沒有id python

    到目前爲止,我曾嘗試:

    driver.find_element_by_xpath("//div[@class='button-status-container'][@type='submit']") 
    
    driver.find_element_by_xpath("//div[@class='button-status-container']//button-status-container[@type='submit']") 
    
    driver.find_element_by_css_selector('.button-status-container[type="button"]') 
    

    所有上述錯誤出與NoSuchElementExceptionthe htlm of submit button

    +0

    嘗試以下XPath: '// DIV /按鈕[包含(文本(), '註冊')]' – Poloq

    +0

    你能提供該頁面上的大部分html用於驗證?在文本中 - 不是截圖。 – pagep

    +0

    @Poloq你的解決方案工作,我不得不找到所有與'註冊'元素,附加到列表,並選擇正確的:register_button = driver.find_elements_by_xpath(「// * [contains(text(),'Register')] 「) register_button [2] .click() – remis4

    回答

    0

    我認爲正確的XPath/CSS選擇應該是:

    driver.find_element_by_xpath("//div[@class='button-status-container']/button[@type='submit']") 
    
    driver.find_element_by_css_selector('.button-status-container > [type="button"]') 
    
    +0

    上面的xpath很好用!謝謝 – remis4

    相關問題