2

I am trying to scroll down the page because the help element overlaps the next page button after I click the button once because the pages moves down. The next button is above the match history table. I tried using

driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

nothing is happening, then I tried using

element=driver.find_element_by_xpath("//table[@class='Table flx-sm dir-r-sm jst-s-sm flx-nw-sm ialgn-st-sm']")
actions = ActionChains(driver)
actions.move_to_element(element).perform()

it gives me the error: MoveTargetOutOfBoundsException: Message: (1009, 835) is out of bounds of viewport width (1536) and height (750)

I tried using

html = driver.find_element_by_tag_name('html')
html.send_keys(Keys.END)

Nothing is moving still.This is the code and the website that I am trying it on.(I also tried using Chrome but I had the same result)

driver = webdriver.Firefox()
url2="https://app.senpai.gg/lol/profile/eune/Primm"
driver.get(url2)
button = driver.find_element_by_xpath('/html/body/div[2]/div/div/section/div/section/main/div[1]/div[1]/div[6]/div/div[1]/div[2]/div/button[2]')
    time.sleep(10)
while true:
    if(button.is_enabled() and button.is_displayed()):
        button.click();
    else:
        break;

1 Answer 1

1
$('[class="el-main"]').scrollBy(0,$('[class="el-main"]').scrollHeight)    

you have to find the scroll element and then use scrolBY on that

driver.execute_script("$('[class=\"el-main\"]').scrollBy(0,$('[class=\"el-main\"]').scrollHeight);")

if you get $ not defined use:

driver.execute_script("arguments[0].scrollBy(0,arguments[0].scrollHeight);", driver.find_element_by_class_name('el-main'))

You can also do:

driver.get(url2)

driver.find_element_by_class_name('el-main').click()

driver.find_element_by_css_selector("body").send_keys(Keys.END)

FIrst you have to bring scroll to focus by clicking it and then send END key on body

finding locator:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

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.