Trying to scroll within a box that has its own scrollbar. Tried numerous ways all have either failed or were not good enough.
heres the html of the scrollbar
<div id="mCSB_2_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 30px; display: block; height: 340px; max-height: 679.6px; top: 0px;" xpath="1"><div class="mCSB_dragger_bar" style="line-height: 30px;"></div></div>
when the "top" value goes up or lower allows for scrolling .the scrollbar ofcourse goes down aswell ..been trying to mimic this but to no avail
some attempts so far
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']")
A = ActionChains(driver1).move_to_element(scrollbar)
A.perform()
A = ActionChains(driver1)
A.perform()
W = driver1.find_element(By.CSS_SELECTOR,".visible-list > .row:nth-child(4)> .investment-item")
W.location_once_scrolled_into_view
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").get_attribute("style")
newscrollbar = str(scrollbar).replace("top: 0px","top: -100px")
driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").__setattr__("style",newscrollbar)
scrollbar =driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").get_attribute("style")
newscrollbar = str(scrollbar).replace("top: 0px","top: -100px")
A = driver1.create_web_element(newscrollbar)
driver1.find_element(By.XPATH,"//aside[@class='sidebar mCustomScrollbar _mCS_2']//div[@class='mCSB_container']").__setattr__("style",A)
Iv tried alot more methods but to no avail ..theres some more details from this link
Using scrollbar by editing attribute using Selenium Python
Thankyou in advance
Heres some way to see it
A = driver1.find_element(By.XPATH,"//div[@id='mCSB_2_dragger_vertical']").get_attribute("style")
print(A) #willReturnEg:position: absolute; min-height: 30px; display: block; height: 537px; max-height: 855px; top: 0px;
Newstyle = str(A).replace("top: 0px;","top: 80px;")
driver1.__setattr__("style",Newstyle)
Get style attribute. Change it as a string to eg: ...top:100px.... setor post attribute on website