如何引用包含冒号的属性? (Selenium/python/xpath/css)

How do I refer to an attribute that contains a colon? (Selenium/python/xpath/css)

example html

每个字段都具有相同的 属性 除了 wire: model 属性,但我不能 link 因为我没有足够的经验来编写正确的选择器。 如果您能帮助我做出正确的选择,我将不胜感激。

这是一个 CSS 选择器,应该可以用来获取 'lastName' 元素,例如:

'input[wire:model="lastName"]'

Here's some hopefully helpful documentation on writing selectors.

.grid > div:first-child input {
   /* this would target Last Name */
 }

.grid > div:nth-child(3) input {
   /* replace 3 with whatever you want. 1 would target Last Name, 2 would target First Name, 3 would target Middle Name
 }

看看这是否有效:-

textValues = driver.find_elements_by_xpath(".//div[@class='space-y-2']/input")
for e in textValues:
    print(e.get_attribute("wire:model"))