Sophisticated Seleneium training IDE Tutotrial, our last post, we created an automated test case to search for SeleniumHQ in Google. Now, we are likely to look at that evaluation in Ruby utilizing Selenium-WebDriver (and search for Tutorials on Selenium instead!).
You may ask ‘Why Ruby?’ or say ‘I do not understand any Ruby!’. Ruby is a great option for writing Selenium Online training because how simple it would be to understand along with how simple it’s to read. In this short section, we aren’t even going to instruct any Ruby yet, we are going to reveal how straightforward Ruby is to read that you do not even need to understand any ahead to follow along!
Let us first have a look at the example that is entire
Need ‘selenium webdriver’
driver = Selenium::WebDriver.for :firefox
Component = driver.locate_component(:name, ‘q’)
Component.send_keys “Tutorials on Selenium”
These couple of lines are all we must remake our Selenium IDE evaluation right into a Ruby & Selenium training tutorials evaluation! Let us analyze the code line by line.
The first one need ‘selenium webdriver online training’ only brings the selenium webdriver videos library into our code to ensure it can be used by us. With that we are now able to control the browser.
Another two lines driver = Selenium videos ::Selenium WebDriver training.for :firefox and driver.navigate.to “http://google.com” essentially create an item from where we can control the browser. We can perform a number of things using the Selenium webdriver thing for example shutting itself, locating components, and browsing to pages. The next three lines then submits the form, and discover an element, the search input signal, utilizing the driver object, sorts in Tutorials on Selenium. Among the remarkable advantages of Ruby is clear searching the code is, without understanding any Ruby exactly what the code is doing, you’ll be able to tell. Eventually, we shut the driver (browser).
Ruby is quite simple to read as we are able to see. Coupled with Selenium online training, we are able to write strong evaluations that go beyond that which we are able to do using the IDE.
We introduced the best way to write an easy test using Selenium WebDriver training Ruby. In this post, we are planning to learn more strategies that people are able to utilize to connect to a browser with Selenium training. First thing we must realize is because there are just two principal objectives when using Tutorials on Selenium. First, there’s the driver object. By doing we created the example
Need ‘selenium webdriver’
driver = Selenium::WebDriver.for :firefox
Particularly, we’re developing a driver variable (a variable is a container) and setting an example of the driver for Firefox in it for us to use. It’s possible for you to make other drivers by passing in chrome other browsers like,:ie, among others. It’s possible for you to locate the full list here: http://selenium.googlecode.com/git/docs/api/rb/Selenium/WebDriver/Driver.html#for-class_method . More significantly is the distant driver which permits US to run but we’ll get to that in a future post.
This driver object has many strategies that people are able to call to connect to the browser. For instance, we used driver.navigate.to “http://google.com” formerly to browse to Google.com. We are able to make use of the exact same bit of code browse to any page like so driver.
Other techniques that are useful include:
- Locate component that is _: This can be one of the main process along side with locate_components (with a s). This permits US to find an element on the webpage and return it.
- This may enable us to socialize with it. We’ll be going into components in another post so stay tuned. As an example, in our last post, we used component = driver.locate_component(:name, ‘q’)
- currrent_url: This can give the present_ url to us. That is advantageous for declarations in your evaluation to confirm that you are to the page that is right. To get this done, we do driver.present_url which will return us a string back using the existing url.
- Name: This may give the name of the webpage to us. Additionally, this is useful can be used in the same way as present_url and for claims.
- Change frame: This can be advantageous for pages which have iframes. This allows the driver to change to the special iframe which is given. To make use of this, you’d call it as driver.switch_to.frame “frame_id”.
In your Selenium training online utilization, these 5 techniques will be the primary driver techniques you will use. In our next installment, we’ll have a look at component level processes that enable us to connect to components on a page rather then the driver like the send_keys system which enabled us to kind “Tutorials on Selenium”.
we are planning to investigate the best way to create some complex evaluations using the IDE. We now possess a test where we go to Google and search. After Tutorials on Selenium HQ is searched for by us, we check the query for Selenium videos is within the search field. Let us change our test case to ensure people are able to confirm that ANY query is going to have exactly the same effect.
Rather than creating a fresh evaluation, let us change the one we made in the last case.
We should have the ability to look for just about any term, not only Selenium video tutorials HQ. Let us break down that which we must change so that you can create this evaluation strong.
We need a method to save this new query.
We need a method to make this new query.
We need a method to remember this new query.
In our case, our query that is new will be something which is different every time this evaluation runs. Let us handle our problems one by one.
Saving a query that is new
We really have to make use of a new Selenium training videos online IDE command to save a fresh query. This command is called ‘store’ and it operates just a little differently then the other orders that we have used up to now.
First, let us add our test case and the store command. To get this done, right-click the command that is open to bring up the context menu and click Add New Command. A new clean command should appear over the command that is open. Now click the clean command as well as in the ‘Command’ argument field below the test case table, kind shop (it should automobile propose the store command as you type so that you can even click that). In the value field, let us sort the word ‘query’. This tells the ‘store’ command that we are likely to name a variable (a variable is a container for information) search Query. We want this later when we recover the query.
Making a fresh query