Answer the question
In order to leave comments, you need to log in
How to click on the button more" in inkedin jobs using selenium?
Hello, I need to get a job description from linkedin, but I've run into a problem that I can't solve. There is a button. Her code looks like this:
I tried a bunch of options from normal
self.driver.find_element_by_id('ember57').click()
to
self.driver.execute_script("document.getElementsByClassName('t-14 t-black--light t-bold artdeco-card__action artdeco-button artdeco-button--icon-right artdeco-button--3 artdeco-button--fluid artdeco-button--tertiary ember-view').click();")
WebDriverWait(self.driver, 1000000).until(EC.element_to_be_clickable((By.ID, 'ember57'))).click()
WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.t-14 t-black--light t-bold artdeco-card__action artdeco-button artdeco-button--icon-right artdeco-button--3 artdeco-button--fluid artdeco-button--tertiary ember-view"))).click()
Answer the question
In order to leave comments, you need to log in
I'll give you a couple of thoughts, suddenly something will work out:
1. Now web frameworks generate these id on the fly, i.e. dynamic id is obtained. Either use another XPath, or selectors, or XPath of the type "//path to the element/tag[contains(@id, "ember")]". The same problem can be with classes (where numbers are used or some obscure character generations).
To check what selenium sees: just run in debug, put a breakpoint and f12 (or ctrl + shift + c) on the element code in the browser. Perhaps you can see why the click is not working.
You can also start searching for XPath in the browser (go to the view of the f12 element code and ctrl + f is already there) and check if the XPath is correct for selenium.
2. Maybe wait_and_click doesn't work that way. I once had a story where this wait didn't work. I broke my head, but I did not find a good solution. It turned out that the simplest thing that could come to mind helped. I made a while loop and tried to click in it for 5-10 seconds, if it is not clicked, and I know for sure that there is such a button on the page, then I did Python's time sleep (1).
The problem was that the libraries for working out the button arrived later, perhaps in the background, although the page was loaded, JS too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question