3

I'm trying to click element of this HTML:

<div class="feed-item__explanation" style="padding-left: 15px;">
     <a href="javascript:" ng-click="carinext()">Load more</a>
</div>

I'm using selenium to process this:

driver.get(url)
while True:
        try:
            driver.find_element_by_xpath('//a[text()="Load more"]')
            print 'found'
        except Exception as e:
            print e
            break

That code can be processed and give output 'found'. But when I'm trying to click that element,

driver.find_element_by_xpath('//a[text()="Load more"]').click()

I'm getting an error like this:

Message: element not visible (Session info: chrome=62.0.3202.94)

Is this a problem to process the AngularJS script?

Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
kucingit3m
  • 45
  • 1
  • 6

1 Answers1

2

You might need to scroll down to required element to be able to click it. Try below code:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC 

load_more = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.LINK_TEXT, "Load more")))
driver.execute_script('arguments[0].scrollIntoView();', load_more)
load_more.click()
Andersson
  • 51,635
  • 17
  • 77
  • 129