标签:eem database ext sites img tle sign step factor
Original URL: https://www.guru99.com/intellij-selenium-webdriver.html
Intellij is an IDE that helps you to write better and faster code. Intellij can be used in the option to Java bean and Eclipse.
In this tutorial, you will learn-
IntelliJ IDEA is a Java Integrated Development Environment (IDE). It is used for software development. It is developed by JetBrains. It comes under apache2 licenced ‘community edition‘ as well as ‘proprietary commercial edition‘. It is the finest available Java IDEs. It provides facilities like advanced code navigation and code refactoring capabilities.
The advantage of using intelliJ is that
For that, we need to have some pre-requisites which are as follow.
The required jar files can be downloaded from Selenium.org official site. After download, the file extracts the .jar files into the desired directory.
Step 1) To download IntelliJ visit the jetbrains site. Here we have selected "Community" Version. You can select "ultimate" version for mobile, web and enterprise development.
Step 2) When you begin downloading, you will see a message like this.
Step 3) In next step, a pop-up window will open. Click on ‘run‘ button.
Step 4) In this step, click on ‘next‘ button in the setup wizard.
Step 5) Another pop-up window will open. Browse your destination folder and click on ‘next‘ button.
Step 6) In this step,
Step 7) In next step, click on ‘Install‘ button.
You can see IntelliJ installing process is in progress.
Step 8) In this step,
Step 9) If you already have an older version of IntelliJ installed in your system. You can import setting from older version to the newer version. Since we don‘t have any previous version installed. We will select the second option.
Step 10) When you click on ‘ok‘ button in the previous step, it will ask for Jetbrain privacy policy agreement. Click on ‘Accept‘ button.
Step 11) In this step, you can set plugin setting.
Step 12) In next step, select the option as per requirement. You will see options like create a new project, import project, open, etc.
Step 13) In this step,
Step 14) In this step, the file we selected in the previous step appears in the project directory.
To support Selenium, you need to configure InelliJ. For that follow the following steps.
Step 1) Launch your IntelliJ IDE and make a new Project. Select File -> New -> Project
Step 2) In the previous step when you Click -> Next. A new screen will open. In this screen, give project name. In our case, we have given name Selenium_Guru99. Then Click -> Finish. Your project has been created in IntelliJ.
Step 3) Now You need to add the Selenium‘s .jar files into intelliJ as external libraries.
For this Click go to File -> Project Structure -> in a project setting tab look for Modules ->Dependencies -> Click on ‘+‘ Sign -> Select for JARs or directories.
Step 4) Select all the selenium .jar files from the directory and subdirectory /lib, where you have extracted after download.
Now, you have successfully added the .jar files into intelliJ. If you see your project structure, then you will notice that you project‘s /src directory is empty.
Step 5) Right Click on /src directory -> New -> Java Class. Your project structure will look as shown below.
Example
We will use the site http://demo.guru99.com/.
In this test scenario
In above result, you can see that
Following is java code for test1.
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class TestSelenium {
public static void main(String[] args){
FirefoxDriver driver=new FirefoxDriver();
driver.get("http://demo.guru99.com/");
WebElement element=driver.findElement(By.xpath("//input[@name=‘emailid‘]"));
element.sendKeys("abc@gmail.com");
WebElement button=driver.findElement(By.xpath("//input[@name=‘btnLogin‘]"));
button.click();
}
}
Summary
This article is contributed by Fahid M and edited by Jeegar M.
[Selenium+Java] How to use IntelliJ IDEA & Selenium Webdriver
标签:eem database ext sites img tle sign step factor
原文地址:https://www.cnblogs.com/alicegu2009/p/9098731.html