Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Location Strategies

  • Choosing a Location Strategy

...

driver.navigate().refresh();Upload A File On A Page

Handling Files

Upload Image to Page

An approach to upload an image to a page is to copy the location of the file to the clipboard, entering it into the search bar and pressing enter.


Code Block
linenumberstrue
StringSelection stringSelection = new StringSelection(documentLocation);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, stringSelection);


WebDriver Wait

Different Types of Wait 

  • Implicit Wait - Instructs the web driver to wait for some time by poll the DOM. Once declared, implicit wait will be available for the entire life of web driver instance.
  • Explicit Wait - With the use of ExpectedConditions, explicit wait is custom and can be adjusted. It will be used in the case that the tester wants the execution to wait for some time until some condition is achieved. Explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code.


Note: Implicit Wait and Explicit wait will maximize wait for element for the time duration specified, If they find the element before the next step will be executed. If you want your test to wait for exact time duration, a better approach would be to implement Thread.sleep.

Thread.sleep - In sleep code it will always wait the mentioned seconds, even in case the page is ready to interact after 1 sec.

Code Block
languagejava
themeConfluence
firstline0
linenumberstrue
try{
  Thread.sleep(1000); //1 second
}catch(InterruptedException e){
	e.printStackTrace();
}