Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

After looking up ways to move a slider on a webpage with Selenium I found an article talking about this piece of code.

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Firefox() driver.get("https://www.seiyria.com/bootstrap-slider")
slider = driver.find_element_by_css_selector("div#example-1 div.slider-handle.min-slider-handle.round")

move = ActionChains(driver)
move.click_and_hold(slider).move_by_offset(40, 0).release().perform()

I tried applying it to my own code but unfortunately to no success. Can anyone maybe help me out with what I'm doing wrong? I can only get to move the slider a little bit to the left but the moment I try changing the values of the MoveAction it wont move anymore.

My code:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
import datetime
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import sys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains

def waitForLoad(inputXPath):
    Wait = WebDriverWait(driver, sys.maxsize - 1)
    Wait.until(EC.presence_of_element_located((By.XPATH, inputXPath)))

def newest_post_clicker():
    post = driver.find_element_by_css_selector('#main > div.infinite-scroll > div:nth-child(1) > div.content')
    title = post.find_element_by_css_selector('h2 > a').text
    author = post.find_element_by_css_selector('p.text-secondary > small:nth-child(4) > a').text
    click_title = driver.find_element_by_link_text(title)
    click_title.click()
    slider = driver.find_element_by_xpath('//*[@id="tipslider"]')

options = Options()
options.add_experimental_option("detach", True)
options.add_argument("--window-size=1920,1080")
options.add_argument('--disable-gpu')#For properly seeing the outputs
## options.add_argument("user-data-dir=/Users/vadim/Library/Application Support/BraveSoftware/Brave-Browser")
options.binary_location =r"C:Program FilesBraveSoftwareBrave-BrowserApplicationrave.exe"
driver_path =r"C:UsersVadimDocumentsCodingchromedriver.exe"
driver = webdriver.Chrome(options = options, executable_path = driver_path)
driver.get('https://www.publish0x.com/login')
waitForLoad('//*[@id="email"]')
E_Mail_vak = driver.find_element_by_xpath('//*[@id="email"]')
E_Mail_vak.send_keys(com')
Pass_vak = driver.find_element_by_xpath('//*[@id="password"]')
Pass_vak.send_keys('')
frame = driver.find_element_by_xpath('//iframe[contains(@src, "recaptcha")]')
driver.switch_to.frame(frame)
Captcha = driver.find_element_by_xpath("//*[@id='recaptcha-anchor']")
Captcha.click()

# input("Please do the captcha and press any key...")

driver.get('https://www.publish0x.com/newposts')
newest_post_clicker()
slider = driver.find_element_by_css_selector('#tipslider')
move = ActionChains(driver)
move.click_and_hold(slider).move_by_offset(40, 0).release().perform()

I am trying to move the slider at the bottom on this page: https://www.publish0x.com/bitcoin-news-blog-bitcoin-dice-casino-news/universal-id-and-blockchain-tech-xdngvvg


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...