==========================================================================================================
Write in front:
The Selenium IDE is an integrated plugin for Firefox, and for now, it is only possible to record scripts via Firefox.
But in real work, we may need to test other browsers such as IE or chrome, so we can do that in other ways. See below for details.
==========================================================================================================
8. Selenium ide-different browsers
The Selenium IDE script only runs tests on Firefox's tool Firefox plugin.
Tests developed with Selenium-ide can be performed on remote control scripts that other browsers save as selenium network drives or selenium.
The script can only run tests on Firefox's tool Firefox plugin.
Tests developed with Selenium-ide can be performed on remote control scripts that other browsers save as selenium network drives or selenium.
More on the remote control of selenium's webdriver and selenium, which is explained in detail in the following chapters.
1th Step : Open the Selenium IDE for any saved tests
2nd Step : Navigate to the "File" menu and select "Export Test Suite as" and the selection will be listed.
3rd Step : Now let's export the script "Webdriver" and save it as the same name.
4th step : As shown, the Save Webdriver file is displayed.
Packagecom.example.tests;ImportJava.util.regex.Pattern;ImportJava.util.concurrent.TimeUnit;Importorg.testng.annotations.*;Import Staticorg.testng.assert.*;Importorg.openqa.selenium.*;ImportOrg.openqa.selenium.firefox.FirefoxDriver;ImportOrg.openqa.selenium.support.ui.Select; Public classBaiduSearch1 {PrivateWebdriver Driver; PrivateString BaseUrl; Private BooleanAcceptnextalert =true; PrivateStringBuffer verificationerrors =NewStringBuffer (); @BeforeClass (Alwaysrun=true) Public voidSetUp ()throwsException {driver=NewFirefoxdriver (); BASEURL= "https://www.baidu.com/"; Driver.manage (). Timeouts (). Implicitlywait (30, Timeunit.seconds); } @Test Public voidTestBaiduSearch1 ()throwsException {driver.get (baseUrl+ "/"); //Error:caught Exception [Unknown command []]Driver.findelement (By.id ("kw") . Clear (); Driver.findelement (By.id ("KW")). SendKeys ("Selenium")); Driver.findelement (By.id ("Su") . Click (); } @AfterClass (Alwaysrun=true) Public voidTearDown ()throwsException {driver.quit (); String verificationerrorstring=verificationerrors.tostring (); if(!"". Equals (verificationerrorstring)) {fail (verificationerrorstring); } } Private Booleaniselementpresent (by) {Try{driver.findelement (by); return true; } Catch(nosuchelementexception e) {return false; } } Private Booleanisalertpresent () {Try{Driver.switchto (). alert (); return true; } Catch(noalertpresentexception e) {return false; } } PrivateString Closealertandgetitstext () {Try{alert Alert=Driver.switchto (). alert (); String Alerttext=Alert.gettext (); if(Acceptnextalert) {alert.accept (); } Else{Alert.dismiss (); } returnAlerttext; } finally{Acceptnextalert=true; } }}
The above is the IDE exported Java code, you can use other ways to execute test cases, run to Chrome and other browsers.
==========================================================================================================
Learning Summary:
1. About Selenium IDE content learning is over.
Selenium IDE's limitations and recording scripts/playback scripts, including the recording scripts that were mentioned during the interview, were laughed at by others, so decided to learn more about Selenium
aspect of the content.
Then, will learn the actual development of Selenium/webdriver, I believe it will be another learning experience.
==========================================================================================================
Selenium-webdriver Self-study selenium-ide different browsers (eight)