I'm having trouble clicking a box using selenium on python. Im going to add all the info I can on here.
I am using the safari WebDriver.
The first picture here shows what the webpage looks like in inspect element mode. I am trying to click on the board titled "ANSYS".
This second picture shows the box where the hyperlink is contained in. I am trying to click this hyperlink. My current code goes something like
driver.implicitly_wait(20)
boards_button = driver.find_element_by_class('board-tile')
boards_button.click()
My logic for using find_element_by_class is based on noticing that the hyperlink is inside the class "board-tile". I have also tried:
by_name('ANSYS')
find_element_by_link_text('ansys')
find_element_by_partial_link_text('ansys')
This third picture shows where the text is placed in the inspect element viewer.
Any advice is greatly appreciated. Thanks in advance.
Related
I have a code in python that uses selenium chromedriver to reach a webpage and collect some data but I want to solve a issue related with a pop-up window. For example, if you go to this webpage https://finance.yahoo.com/quote/BAC?p=BAC you will get two pop-up windows. One is for the acceptance of the collection of personal data (image below) and this I can handle well with the following code:
...
# Go to the website:
driver.get(main_url)
# Click accept button
driver.find_element(By.NAME, "agree").click()
...
The second one (image below) however I'm not being able to dismiss. I want the code to click on the "Maybe later" button but I cant find the button ID. Can someone help me?
I am building a crawling code on a web page running only on IE11.
My problem is that python selenium,selenium.webdriver.Ie, find completely different element of HTML
element = driver.find_element_by_xpath("//*[text()='1']")
I look for element which text is 1 on the calendar and element.text's output is also 1 in juypter notebook like picture.
enter image description here (I can't be embedded because I'm a Newbie. I'm sorry.)
But if i operate element.click() in browser(driver, HTML),18 is clicked in browser.
enter image description here
Why did my code operate like this?
I am trying to get python selenium to click on the description box for eBay selling but it can't find it. I have tried to switch to the frame but it can't find them either. This is the code I have now.
driver.switch_to.frame('v4-183txtEdit_st')
driver.find_element_by_xpath('//*[#id="v4-183txtEdit_st_wr"]/div[2]').click()
This is an image of the description box I am trying to get selenium to click on.
This is it but with inspect element.
I was already in another frame so I had to exit. This is the code I used.
driver.switch_to.parent_frame()
Using Python + Selenium to create a web crawler/scraper to notify me when new homework is posted. Managed to log into the main website, but you need to click a link to select your course.
After searching through the HTML manually, I found this information about the link I usually click (The blue box is the link).
However, no button that seems clickable. So I searched the page for the link I knew it should redirect me to, and I found this:
It looks like a card, which is a new data structure/object for me. How can I use an automated web crawler to click this link?
Try the following:
ui.WebDriverWait(self.driver, timeout).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".title.ellipsis")))
driver.find_element_by_css_selector(".title.ellipsis").click()
Hope it helps you!
I'm trying to click on the webpage "https://2018.navalny.com/hq/arkhangelsk/" from the website's main page. However, I get this error
selenium.common.exceptions.ElementNotInteractableException: Message:
There's nothing after "Message:"
My code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox()
browser.get('https://2018.navalny.com/')
time.sleep(5)
linkElem = browser.find_element_by_xpath("//a[contains(#href,'arkhangelsk')]")
type(linkElem)
linkElem.click()
I think xpath is necessary for me because, ultimately, my goal is to click not on a single link but on 80 links on this webpage. I've already managed to print all the relevant links using this :
driver.find_elements_by_xpath("//a[contains(#href,'hq')]")
However, for starters, I'm trying to make it click at least a single link.
Thanks for your help,
The best way to figure out issues like this, is to look at the page source using developer tools of your preferred browser. For instance, when I go to this page and look at HTML tab of the Firebug, and look for //a[contains(#href,'arkhangelsk')] I see this:
So the link is located within div, which is currently not visible (in fact entire sub-section starting from div with id="hqList" is hidden). Selenium will not allow you to click on invisible elements, although it will allow you to inspect them. Hence getting element works, clicking on it - does not.
What you do with it depends on what your expectations are. In this particular case it looks like you need to click on <label class="branches-map__toggle-label" for="branchesToggle">Список</label> to get that link visible. So add this:
browser.find_element_by_link_text("Список").click();
after that you can click on any links in the list.