【问题标题】:Button not clicking and getting no errors with Selenium PythonSelenium Python 按钮未单击且未出现错误
【发布时间】:2021-01-17 16:05:31
【问题描述】:

this buttons are not getting clicked

agree_button = driver.find_element_by_xpath('//*[@id="rightsDeclaration"]')
submit = driver.find_element_by_xpath('//*[@id="submit-work"]')

def upload():
  agree_button.click()
  time.sleep(1)
  submit.click()

upload():

但是我注意到,当函数被调用时,url 会像这样被选中:

Url selected when the function is called

我尝试使用 id、name、xpath 和所有内容进行定位

按钮:

我还注意到页面向下滚动了一点(而不是单击 ofc),就是这样。有什么问题?

完整代码:

copy_settings_link = "https://www.redbubble.com/portfolio/images/68171273-only-my-dog-understands-me-beagle-dog-owner-gift/duplicate"


def copy_settings():
    driver.get(copy_settings_link)

    replace_image_button = driver.find_element_by_xpath('//*[@id="select-image-base"]')

    time.sleep(1)

    replace_image_button.send_keys(Path_list[0])

    upload_check = driver.find_element_by_xpath(
        '//*[@id="add-new-work"]/div/div[1]/div[1]/div[1]/div')  # CHECKING UPLOAD
    while True:
        if upload_check.is_displayed() == True:
            print('Uploading...')
            time.sleep(1)
        else:
            print('Uploading Finished')
            time.sleep(1)
            break


copy_settings()


def upload():
    agree_button.click()
    time.sleep(1)
    submit.click()

upload()

【问题讨论】:

    标签: python python-3.x selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    问题已解决的家伙: 这个

    chrome_options.add_argument("user-data-dir=C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\User Data") # Stay LOGGED IN
    

    谁能解释一下这段代码是如何工作的?它让我在网站上保持登录状态

    【讨论】:

      猜你喜欢
      • 2017-09-12
      • 2016-04-29
      • 2020-01-08
      • 1970-01-01
      • 2023-03-23
      • 2016-01-19
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      相关资源
      最近更新 更多