Archive For The “Selenium Webdriver” Category

Save image in webdriver by java

By |

import java.awt.image.BufferedImage; import java.io.File; import java.net.URL;   WebElement imageEl = driver.findElement(By.xpath(“//img[@alt=’image’]”)); String imageElURL= imageEl .getAttribute(“src”); URL imageURL = new URL(imageElURL); BufferedImage saveImage = ImageIO.read(imageURL); ImageIO.write(saveImage, “png”, new File(“D:” + File.separator + “image.png”));

Read more »

Run TestNG class in main method

By |

public static void main(String[] args) { TestListenerAdapter testListenerAdapter = new TestListenerAdapter(); TestNG testng = new TestNG(); testng.setTestClasses(new Class[] { test.class }); testng.addListener(testListenerAdapter); testng.run(); }

Read more »

Using dataprovider in TestNG

By |

package com.automation; import …;   @Listeners({com.automation.listenner.Local.class}) public class testClass{ AppiumDriver driver = null; @BeforeMethod public void beforeMethod() { } @DataProvider public Object[][] inputDatas() { Object[][] inputDatas = null; String csvFile = “C:” + File.separator + “file.csv”; try { List<String> lines = Files.readAllLines(new File(csvFile).toPath()); inputDatas = new Object[lines.size()][10]; String[] datas = new String[10]; String line =…

Read more »

Using listener in TestNG class

By |

import com.automation.Example; @Listeners({com.automation.listenner.LocalSuiteListener.class, com.automation.listenner.LocalReportListener.class}) public class testClass{

Read more »

Selenium Webdriver – Setting Up a Selenium-WebDriver Project

By |

To install Selenium means to set up a project in a development so you can write a program using Selenium. How you do this depends on your programming language and your development environment. Java The easiest way to set up a Selenium 2.0 Java project is to use Maven. Maven will download the java bindings…

Read more »

Chọn phiên bản thư viện khi có nhiều phiên bản của cùng một thư viện trong các thư viện tải từ maven

By |

Kịch bản issue: Một thư viện được import trong nhiều thư viện khác và được tải về từ maven, dẫn đến xảy ra tình trạng bị conflict phiên bản thư viện và khi sử dụng có thể không đúng phiên bản thư viện mình muốn sử dụng Ví dụ: Thư viện commons-io có trong 2…

Read more »

Fix error “Path must include project and resource name” when update maven in elipse

By |

Solution 1: Remove or comment: “<sourceDirectory>.</sourceDirectory>” in pom.xml Solution 2: copyright https://dev.eclipse.org/mhonarc/lists/m2e-users/msg05170.html I have recently changed the setup of a project and received this error: java.lang.IllegalArgumentException: Path must include project and resource name: /og-analytics at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63) at org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:2069) at org.eclipse.core.internal.resources.Container.getFolder(Container.java:201) at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.isContained(AbstractJavaProjectConfigurator.java:469) at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.isNonOverlappingResourceDescriptor(AbstractJavaProjectConfigurator.java:461) at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.addResourceDirs(AbstractJavaProjectConfigurator.java:422) It causes an error popup every time the m2e project…

Read more »

Lưu ảnh bằng selenium webdriver

By |

package quan.tutorial.com; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import org.apache.commons.io.FileUtils; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.Point; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import com.vinecom.adayroi.core.DriverUtil; public class SaveImageByElement { public static void main(String[] args) { WebDriver driver = null; try { driver = DriverUtil.getInstanceForAllOS(“chrome”); driver.get(“http://www.seleniumhq.org/docs/_images/chapt3_img01_IDE_Installation.png”); WebElement imageEl = driver.findElement(By.tagName(“img”)); File image = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); BufferedImage fullImg…

Read more »

Selenium Webdriver – Introduction

By |

Introducing WebDriver The primary new feature in Selenium 2.0 is the integration of the WebDriver API. WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the…

Read more »