Both “assert” and “verify” commands check whether the given condition is true or false : Assert: It stops the execution of the testing if the given condition is false else continue with the further tests. Example: assertEquals (expectedMessage, actualMessage); Verify: It doesn’t stop the flow of execution irrespective of the condition being true or false. driver.close() It closes the currently active window on which the user is working. driver.quit() It closes all the windows opened by the driver. Note: Both the commands don’t take any parameter and don’t return any value either. This code can replicate right-click action: Actions action = new Actions(driver); WebElement element = driver.findElement( By.id("elementId")); action.contextClick( element).perform(); This code can replicate mouse hover action: Actions action = new Actions(driver); WebElement element = driver.findElement ( By.id("elementId")); action.moveToElement( element).perform(); driver.findElement(By.id("q")); driver.findElement(By.name("q")); driver.findElement( By.xpath("//input[@id==’neptune’])); driver.FindElement(By.LinkText ("edit this page")).Click(); driver.findElement( By.className("Header")); driver.findElement( By.tagName("select') ).click(); driver.findElement( By.linkText("NeptuneWorld") ).click(); driverlindElement( By.partialLinkText("Neptune") ).click(); WebDriverWait wait = new WebDriverWait(driver, 10); WebElement messageElement = wait.until( ExpectedConditions .presenceofElementLocated( By.id(”loginToNeptuneworld"))); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.navigate().refresh(); - This method refreshes the current page. driver.navigate().to( "https://neptuneworld.in/"); - Navigates to the provided URL. driver.navigate().forward(); - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything. driver.navigate().back(); - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything. JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript( "window.scrollBy(0,1000)"); The window is scrolled vertically by 1000 pixels Yes! Text can be entered into a textbox using JavaScriptExecutor JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript( "document.getElementById( ‘email').value= WebElement dp = driver.findElement( By.id("testingDropdown")); Select dropdown = new Select(dp); dropdown.selectByIndex(5); or dropdown.selectByValue(“Neptune”); or dropdown.selectByVisibleText(“Neptune World”); WebElement browseBtn = driver.findElement( By.id("uploadfile")); browseBtn.sendKeys("D:\\neptune.txt"); I Hope you got something from this article !! If you have something in mind, Write in the comment section. Thanks for Reading!! What is the major difference between “assert” and “verify” cmd's in Selenium?
What is the difference between driver.close() and driver.quit() command in Selenium?
How can we create right-click and mouse hover actions in Selenium?
Different types of Locating strategies in Selenium ?
Locating by ID:
Location by Name:
Location by Xpath:
Locating Hyperlinks by Link Text:
Locating by ClassName:
Locating by TagName:
Locating by LinkText:
Locating by PartialLinkText:
What is the Syntax for defining explicit and Implicit wait for 10 seconds ?
Explicit Wait :
Implicit wait :
What are the different types of navigation commands ?
How to scroll down a page using JavaScript?
First, create a JavaScript object.
Now, Scroll down to the desired location.
Is there a way to type in a textbox without using sendKeys()?
How to select a value from a dropdown in Selenium WebDriver?
How to upload a file in Selenium WebDriver?
Browse button located:
Pass the path of the file to be uploaded using sendKeys methods: