self.browser.get('https://www.mathblog.dk/tools/infix-postfix-converter/')
returnValue = self.browser.find_element_by_xpath("//*[@id='post-4778']/div/form[1]/p/input[1]").text中置框
.text函数不工作,它返回一个空字符串。为什么会发生这种情况?
发布于 2020-06-06 09:09:36
要从input字段中提取文本,请使用.get_attribute('value')。
您的xpath是正确的,但css选择器比xpath更好:
returnValue = self.browser.find_element_by_css_selector("input[name=infix]").get_attribute('value')
print(returnValue)https://stackoverflow.com/questions/62225723
复制相似问题