Click here to Skip to main content
15,177,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is an addition to the first version of the question i asked since i still can not solve it so more details are in here Selenium scroll into view with a twist Python

I have managed to collect the attribute ..but have no idea how to edit it to work in the way i want..i want to be able to just simply scroll down i have tried multiple different ways to acheive this but none of them seem to work

Here is the code of the countless ways i have tried to figure this out.

scrollbar = str(driver1.find_element_by_xpath("//div[@id='mCSB_2_dragger_vertical']").get_attribute("style"))
    driver1.execute_script("document.getElementByXPath('lga') = '200px';")
    scrollbar = str(driver1.find_element_by_xpath("//div[@id='mCSB_2_dragger_vertical']").get_attribute("style"))
    # new_style = driver1.find_element_by_xpath("//div[@id='mCSB_2_dragger_vertical']").get_attribute("style").replace('top: 0px', 'top: 300px')
    # driver1.execute_script('arguments[6].setAttribute("style", "%s")' %new_style, scrollbar)
    # print(scrollbar)
    # element = driver1.find_element_by_xpath("//div[@id='mCSB_2_dragger_vertical']")
    # A = driver1.execute_script("argument[0]",element)

    # A =driver1.execute_script("arguments[0].value = 'top: 100px'", element)
    # print(A)
    # driver1.execute_script("arguments[0].setAttribute('top:', 'top: 300px')", element)

    # div_elem = driver1.find_element_by_xpath("//div[@id='mCSB_2_dragger_vertical']")
    # print(div_elem.text)
    # new_style = div_elem.get_attribute('style').replace('top: 0px', 'top: 300px')
    # driver1.execute_script('arguments[0].setAttribute("style", "%s")' % new_style, div_elem)
    # print(div_elem.text)
    # newvalue = "-300px"
    # splitting = scrollbar.split(": ")
    # indextochange = str(splitting[6])
    # EntirenewAttribute = str(scrollbar.replace(indextochange,newvalue))
    # driver1.execute(scrollbar.replace(scrollbar,EntirenewAttribute))#EntirenewAttribute

The first print line correctly returns the data i want to change

position: absolute; min-height: 30px; display: block; height: 229px; max-height: 675px; top: 0px;
When using the scrollbar the "top"value changes ...hence i was trying to automatically change it.but to no avail.

What I have tried:

Tried everything from extracting the entire attribute line .. editing it and then it back in to just changing the "top" only

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900