The blog gives you idea of testing and automation testing example of selenium webdriver,SQl and Jmeter, you see the basic example of selenium web driver and get idea how to do automation testing,

How to convert testng html report into PDF

how to search all .pdf or .txt file from the directory


Get Css attribute of any element

When you do automation testing, you have check which backgroud-color, font style, padding or margin is used for a element. and you can also check Css attribute of any element with the help of selenium script. Below it the code which help you to verify css attribute.


import java.util.List;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class SearchWebElements
{
WebDriver driver = new FirefoxDriver();
private String baseUrl= "http://docs.seleniumhq.org/docs/03_webdriver.jsp#introducing-the-selenium-webdriver-api-by-example";
@Test
public void findElementsColor(){
driver.get(baseUrl);
try{
    WebElement getCssValueElement = driver.findElements(By.id("by-id"));
String element_value = getCssValueElement.getCssValue("font-size");
Assert.assertequal(element_value,"Arial");
if(getCssValueElement.getCssValue("backgroud-color").contains("#ffffff"))
{
    System.Out.Print("Color Verify")'
}
else{
 System.Out.Print("Color Not Verify")'
}
    }
}
finally{
    //driver.close();
    driver.quit();
}
}
}
some time when browser convert #fffff  To rga(45.45.6.0), so Instead of #ffffff you can also used rga(45,45,6,0)

Mover Slider From one position to other

I have a web application which have a slider, when I click or drag pointer on slider then below displayed data should changed. user can move slider to specific point eg: 2, 6, 8 and 10 Days.
I can drap slider at 2 days then data of 2 day displayed in below table.

I write code for that slider, it is very simple and under stable. you can choose "postionOfSlider" value should be any.


public static void dragdrop(){
     int postionOfSlider=10;
        WebElement slider = driver.findElement(By.id("dragdrop"));  // Position of element
        int width=slider.getSize().getWidth();   // Width of Slider or element
        Actions move = new Actions(driver);
        move.moveToElement(slider, ((width*postionOfSlider)/100), 0).click();
         // move to a specific point on the dragpoint
       move.build().perform();
       System.out.println("Slider moved");

      }

we can also used for-loop to drag slider or move slider from one point to another point on the webpage with the help of above code.

Powered by Blogger.