简体   繁体   English

Robot Framework浏览器支持

[英]Robot Framework browser support

Has the robot framework support for IExplorer or only for Firefox and Chrome? 机器人框架是否支持IExplorer或仅支持Firefox和Chrome? (If yes, how to configure it?) (如果是,如何配置?)

Thanks! 谢谢!

Robot Framework does not, in itself, support any particular browser, so I am guessing you are referring to either SeleniumLibrary or Selenium2Library which use selenium and selenium 2 respectively. Robot Framework本身不支持任何特定的浏览器,因此我猜您是指分别使用硒和硒2的SeleniumLibrary或Selenium2Library。 The browser support of these is well documented at seleniumhq and there is much support out there. seleniumhq充分记录了对浏览器的支持,并且那里有很多支持。 It is recommended for new projects to use Selenium2Library as this will receive ongoing support. 建议新项目使用Selenium2Library,因为它将得到持续的支持。

Download IEdriver exe from here and put this exe file in Scripts folder of your Python installation directory. 此处下载IEdriver exe ,并将此exe文件放入Python安装目录的Scripts文件夹中。 For eg, in my case it is C:\\Python27\\Scripts . 例如,在我的情况下是C:\\Python27\\Scripts

Ride will now launch IE for you. Ride现在将为您启动IE

请检查驱动程序与浏览器的兼容性。

Open Browser ${WEBAPPURL} ${BROWSER} is the keyword to open the browser. 打开浏览器${WEBAPPURL} ${BROWSER}是打开浏览器的关键字。

  • For Firefox you can use firefox/ff instead of ${BROWSER} 对于Firefox,您可以使用firefox/ff代替${BROWSER}
  • For Google Chrome you can use googlechrome/gc/chrome instead of ${BROWSER} 对于Google Chrome浏览器,您可以使用googlechrome/gc/chrome代替${BROWSER}
  • For Internet Explorer you can use internetexplorer/ie instead of ${BROWSER} 对于Internet Explorer,您可以使用internetexplorer/ie代替${BROWSER}

For Firefox you don't need any driver but IE and Chrome you need to install the drivers 对于Firefox,您不需要任何驱动程序,但IEChrome则需要安装驱动程序

You can find the installers in and info here for Chrome and here for IE 您可以在中找到安装程序,并在此处找到有关ChromeIE的信息。

You might have already known of IE driver. 您可能已经知道IE驱动程序。 Apart from that you also need to check Python version- Selenium2 version - IE Driver version - IE browser version compatibility. 除此之外,您还需要检查Python版本-Selenium2版本-IE驱动程序版本-IE浏览器版本兼容性。

In addition to @theheadofabroom 's answer, I should add that Internet Explorer does not play well with Robot Framework . 除了@theheadofabroom的答案外,我还应该补充一点, Internet ExplorerRobot Framework上不能很好地发挥作用。 Your test might not work for any number of reasons on IE while it may work just fine on FireFox and Chrome , but the most common is timing. 由于多种原因,您的测试可能无法在IE上运行,而在FireFoxChrome上却可以正常运行,但最常见的是计时。 IE is just slow enough that when Robot Framework goes to click on the next element, it searches the page for it, but it hasn't loaded in yet. IE足够慢,以至于当Robot Framework去单击下一个元素时,它会在页面中搜索它,但尚未加载。 As long as you have the Selenium webdriver for IE installed correctly and have written your Robot Framework code correctly, I'd recommend adding some Sleep keywords between actions to slow your code down and increase the probability that the element you want to click will load before Robot Framework searches the page for it. 只要您已正确安装IESelenium Webdriver并正确编写了Robot Framework代码,我建议在操作之间添加一些Sleep关键字以减慢代码速度并增加要单击的元素在加载之前的概率Robot Framework在页面上搜索它。 This is especially true if you're writing for Chrome and want to send it to either Firefox or IE . 如果您正在为Chrome编写并将其发送到FirefoxIE,则尤其如此。

Robot class supports keyboard inputs regardless of the browser. 机器人类支持键盘输入,而与浏览器无关。 It is a class from the java.awt package and not specific to any browser. 它是java.awt包中的类,并且不特定于任何浏览器。 It is used in automation for performing operations on the web browser(stand alone application) in which a web-page is being automated 在自动化中用于在正在使网页自动化的Web浏览器(独立应用程序)上执行操作

Note that it cannot perform operations directly on the web browser as it's a stand alone application, but can make use of keyboard shortcuts to indirectly perform the operation. 请注意,它是一个独立的应用程序,因此无法直接在Web浏览器上执行操作,但是可以利用键盘快捷键间接执行该操作。

For example, if you want to open a new tab in a browser, you can use the Robot class to press Ctrl+t instead of trying to click on the new tab. 例如,如果要在浏览器中打开新选项卡,则可以使用Robot类按下Ctrl+t而不是尝试单击新选项卡。 Code to use it to open a new tab in your program 使用它在程序中打开新标签的代码

Webdriver driver = new ChromeDriver(); //FirefoxDriver(), IntrrnetExplorerDriver();
driver.get("......");
//code goes here
//to open a new tab
Robot rob = new Robot();
rob.keyPress(Keys.VK_CTRL);
rob.keyPress(Keys.VK_t);
rob.keyRelease(Keys.VK_CTRL);
rob.keyRelease(Keys.VK_t);
//itetator to switch between the tabs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM