我正在尝试value=" "从此代码中获取信息。只要类中有橙色这个词,我就想存储这个值。
这种情况下的预期结果是将值“JKK-LKK”存储在变量中。
<input type="text" readonly="" class="form-control nl-forms-wp-orange" value="JKK-LKK" style="cursor: pointer; border-left-style: none;>
我试过使用
text = driver.find_elements_by_xpath("//*[contains(text(), 'nl-forms-wp-orange')]").get_attribute("value"))
但我得到:
AttributeError: 'list' Object has no attribute 'get_attribute'.
我也尝试过getText("value"),但我得到的不是有效的 Xpath 表达式。
如果我尝试只使用
driver.find_elements_by_xpath("//*[contains(text(), 'nl-forms-wp-orange')]")
列表变为空。所以我觉得我可能会遗漏一些其他关键部分。我可能做错了什么?