首页 > 解决方案 > 对如何迭代这个 xpath 感到困惑

问题描述

我正在遍历一个 JSON 文件并将其内容同时粘贴到网站上的文本编辑器上。


incrementor = 1

for x in range(len(jsonL)):
    jsonL[x]["question"] = jsonL[x]["question"].strip()
    if incrementor//2 != 1:
        element = browser.find_element_by_xpath(f'//div[contains(@title, "Rich Text Editor, 
        editor{incrementor}")]')
        element.send_keys(jsonL[x]["question"])
        incrementor += 1

在下一次迭代中,我想要

element.send_keys(jsonL[x][choices[0]])

我怎样才能做到这一点?

标签: pythonjsonseleniumloops

解决方案


推荐阅读