[英]How to retrieve HTML information about specific actions using WebDriver
I'd like to reverse engineer Selenium WebDriver to write my tests for me as I use it.我想对 Selenium WebDriver 进行逆向工程,以便在我使用它时为我编写测试。 This would entail opening a WebDriver on screen, and clicking around and using it as normal.这将需要在屏幕上打开一个 WebDriver,然后像往常一样点击和使用它。 It will output instructions like self.driver.find_element_by_id('username-box')
or whatnot for me, instead of the time-wasting of right-clicking the "Inspect element" each time I write a test.它将输出像self.driver.find_element_by_id('username-box')
或诸如此类的指令,而不是每次编写测试时都浪费时间右键单击“检查元素”。
Ideally this will give me a nice xpath which is more exact.理想情况下,这会给我一个更好的 xpath,它更准确。 How do I retrieve the Xpath/way to recreate actions when manually using Selenium WebDriver?手动使用 Selenium WebDriver 时,如何检索重新创建操作的 Xpath/方式?
As Nameless said, it won't solve the "make me an efficient XPath", etc. problem that you are talking about but you can install Selenium IDE (a FF plugin) and record your scenarios and then export them into various languages.正如无名所说,它不会解决你所说的“让我成为一个高效的 XPath”等问题,但你可以安装 Selenium IDE(一个 FF 插件)并记录你的场景,然后将它们导出为各种语言。 It doesn't write the best code but you can get an idea of what it does with a quick download and install.它不会编写最好的代码,但您可以通过快速下载和安装了解它的作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.