Scroll down specific area by Selenium Python - python

How to scroll down specific area of webpage.
Because i need to scroll down on linkedin message section.
NOT scroll down entire screen. Scroll down on specific area.
Please help me.
Please check image. CLICK HERE

Use :
selenium driver.execute_script() for running js script
javascript or jQuery method scroll
css selectors for finding your element in the list

Related

Python selenium can't find the search box in ebay

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()

why window.scrollTo() doesn't work with pages like YouTube?

I am trying to scrape with Selenium but I need to load all the content of the page by moving to the end of the website. But when I execute: driver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
the program doesn't do anything at all. I wonder if it's because the page that I'm scraping has a personalized scrollbar.
That's because document.body.scrollHeight is zero, so it doesn't scroll anything.
You can scroll to an arbitrary large value to scroll down or instead use document.documentElement.scrollHeight.
Check this question for more details.

With selenium on python don't know how to shut down a banner which is preventing selenium from accessing the page content

I'm trying to open a site with Selenium (with Python) using Chrome browser, but when I do, a full screen promo banner immediately pops-up and I can't access the site content unless I close it.
On the top right there is an "x" as if it was a quit button, but actually it's an element ::before
and from its description it seems to me that it doesn't contain any button element.
If I operate manually, both clicking on the x and on the upper part of the page outside the banner, the latter closes, but I really don't understand how to access it with selenium.
The webpage I'm trying to open is https://sports.bwin.it/it/sports
Needless to say I'm quite inexperienced, so I hope this question won't sound too basic, but I wasn't able to find a solutione in the selenium docs or on the web; if someone could give me any hint I would appreciate it.
This is a screenshot from the page I'm talking about
This is part of the html code from the web page; the element I am talking about is the one pointed by the arrow;
Based on your screen shot the xpath you want to use would be something like this:
//*[#data-id='dj_sports_c_ovl_br']//span
full code would be something like this:
element = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH, "//*[#data-id='dj_sports_c_ovl_br']//span"))
)
element.click();

Trouble clicking box without text using selenium python safari WebDriver

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.

Finding elements after click using Selenium

I can't figure this one out.
I am working on this site and I have used selenium in Python to click on the first element under the class name "yellow showPopupUnder" (the main part of the screen where there are 20 yellow rows of information about houses).
After I get Selenium to click on that row it opens up and shows more information. I am interested in the part where there are 'checked' and 'unchecked' boxes. Those checked boxes are in a div like so:
<div class="v_checked">
And the unchecked boxes are in a div like so:
<div class="v_unchecked">
I have tried reaching them in a few ways:
driver.find_element_by_class_name('v_checked')
driver.find_element_by_css_selector(".v_checked")
driver.find_element_by_xpath("//div[#class='v_checked']")
I have also tried to use the absolute xpath. All of these don't work and I get a "NoSuchElementException: no such element: Unable to locate element"
Does anybody know how to retrieve the data from those boxes?
Thank you!
There is a iframe used that opens up and shows more Information where those Checkbox are shown. You have to navigate to that iframe. You can do something like this:
## switch to the iframe ##
driver.switch_to_frame(driver.find_element_by_id("ad_iframe_2_1_1731213"))
## then you can search your checkbox##
driver.find_element_by_class_name('v_checked')
## Switch back to the "default content" (that is, out of the iframes) ##
driver.switch_to_default_content()

Categories