0

I am trying to scrape a website. Where in I have to press a link. for this purpose, I am using selenium library with chrome drive.

from selenium import webdriver

url = 'https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25222&siteid=5011&noback=1&fromSM=true#Applications'
browser = webdriver.Chrome()
browser.get(url)
time.sleep(3)

link = browser.find_element_by_link_text("Don't have an account yet?")
link.click()

But it is not working. Any ideas why it is not working? Is there a workaround?

0

1 Answer 1

1

You can get it done in several ways. Here is one of such. I've used driver.execute_script() command to force the clicking. You should not go for hardcoded delay as they are very inconsistent.

Modified script:

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

url = 'https://sjobs.brassring.com/TGnewUI/Search/Home/Home?partnerid=25222&siteid=5011&noback=1&fromSM=true#Applications'

driver = webdriver.Chrome()
driver.get(url)

item = wait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "a[ng-click='newAccntScreen()']")))
driver.execute_script("arguments[0].click();",item)
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, How did you come up with "arguments[0].click();" & "a[ng-click='newAccntScreen()']". sorry I am new to these.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.