使用Python Selenium通过javascript获取元素

我正尝试使用如下所示的javascript获取python硒中的列表

lists = browser.execute_script("document.getElementById('permalink-overlay').getElementsByClassname('u-dir')")

但是,终端显示错误'NoneType' object

如何通过javascript从python硒中获取列表?

realqishangbaxia 回答:使用Python Selenium通过javascript获取元素

你做错了

from tkinter import *

SubTests = ['Test 1','Test 2','Test 3','Test 4','Test 5','Test 6','Test 7','Test 8','Test 9','Test 10']

class GUI:
    def __init__(self,master=None):
        self.master = master
        self.choice = IntVar(value=-1)  # Set to a value no button will produce.
        self.rb = []
        for i,subtest in enumerate(SubTests):
            radio_btn = Radiobutton(master,text=subtest,fg='black',value=i,variable=self.choice,command=self.btn_callback)
            radio_btn.grid(column=0,row=i+2,sticky=W,padx=5)
            self.rb.append(radio_btn)

    def btn_callback(self):
        choosen = self.choice.get()  # Index of button pressed.
        subtest = self.rb[choosen].cget('text')  # Button's text.
        print('You chose: {}'.format(subtest))


root = Tk()
root.geometry('940x550')
root.resizable(FALSE,FALSE)
root.title("GUI Template")

display = GUI(root)

root.mainloop()

或类似的东西

本文链接:https://www.f2er.com/3140120.html

大家都在问