Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在为我的公司进行自动浏览器测试,我希望能够从浏览器中捕获文本并将其添加到字符串(例如订单号)中。我该怎么做?我知道如何找到包含文本的元素,但是如何存储它以供以后使用?非常感谢!(我使用的是 Python 2.7)。
将文本分配给变量并稍后使用。
browser = webdriver.Firefox() browser.get('http://foo.com') elem = browser.find_element_by_id('foo') txt = elem.text # now the element text is stored in the "txt" variable