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?

0

1 Answer 1

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()
Sign up to request clarification or add additional context in comments.

3 Comments

I have tried it and gave an error with no messages, like Message:
What if to replace load_more.click() with WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Load more"))).click()?
OH sorry, i got typo there, the first solution is the answer, many thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.