【问题标题】:How to get elements of next page after changing pages with a javascript command?使用javascript命令更改页面后如何获取下一页的元素?
【发布时间】:2021-08-30 14:34:02
【问题描述】:

driver.execute_script("paginateGayrimenkul(2);") 此代码应将 webdriver 带到网站的第二页。但是当我搜索元素时,我仍然会得到第一页的元素

分页Gayrimenkul(2);命令适用于 chrome 的控制台,所以我知道这不是问题

我的问题是:如何获取我的代码应该指向的新页面的元素?

我试过但没用的方法:

newURl = driver.window_handles[0]
driver.switch_to.window(newURl)

【问题讨论】:

标签: javascript python selenium web-scraping


【解决方案1】:

你可以应用类似的东西:

current_url = driver.current_url # capture current page url
driver.execute_script("paginateGayrimenkul(2);") # calling the new url
WebDriverWait(driver, 15).until(EC.url_changes(current_url)) # wait until you have been redirected to the new page
# here you can find the element you want in the new page

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-01
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 2012-07-05
    相关资源
    最近更新 更多