Click button by find_element_by_class_name not working python selenium webdriver NOT working

后端 未结 2 1090
故里飘歌
故里飘歌 2020-12-18 05:50

I\'m trying to add contacts on LinkedIn using Python and Selenium. I\'m attempting to do so by adding the contact suggestions made by LinkedIn in the \"Network\" tab (https:

相关标签:
2条回答
  • 2020-12-18 06:07

    You should use find_elements for finding all elements with same class Try this to get all elements:

    elements = driver.find_elements_by_class_name("mn-person-card__person-btn-ext.button-secondary-medium")
    

    then use a for loop to click each of them. For example:

    for e in elements:
        e.click()
    
    0 讨论(0)
  • 2020-12-18 06:19

    The way you are trying to use find_element_by_class_name locator is not correct as this locator doesn't support compound classes within.

    You need to use either xpath or cssSelector if class attribute have more then one class name :

    driver.find_element_by_xpath("//button[@class='mn-person-card__person-btn-ext button-secondary-medium']").click()
    
    0 讨论(0)
提交回复
热议问题