To debug the tests in no display servers with XVFB display. Using ImageMagick – Install imagemagick – sudo yum install ImageMagick – Suppose the browser runs at display :99 using xvfb Then – In linux terminal type – export DISPLAY=:99 – Then type – “import -window root example.png” The above command will create a screenshot […]
https://addons.mozilla.org/en-US/firefox/addon/element-locator-for-webdriv/ https://addons.mozilla.org/en-us/firefox/addon/firepath/ https://saucelabs.com/builder http://www.saucelabs.com/addons/selenium-builder-latest.xpi
Download pdfbox and fontbox jars from https://pdfbox.apache.org/download.cgi To read pdf file and verify the content is present in the pdf using. import java.io.BufferedInputStream; import java.io.IOException; import java.net.URL; import org.apache.pdfbox.pdfparser.PDFParser; import org.apache.pdfbox.util.PDFTextStripper; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class PdfRead { WebDriver driver = new FirefoxDriver(); public void verifyPdfContent(String[] values) throws IOException { URL url […]
FirefoxProfile fProfile = new FirefoxProfile(); fProfile.setAcceptUntrustedCertificates( true ); fProfile.setPreference( "security.enable_java", true ); fProfile.setPreference( "plugin.state.java", 2 ); WebDriver driver = new FirefoxDriver( fProfile ); plugin.state.java = 0 never activate, 1 = ask to activate, 2 = always activate
– Download sikuli-setup.jar from http://www.sikuli.org/download.html – Copy to a folder – Double click on the jar file or run it from command prompt (make sure you have java installed 6/7), follow the instructions. – In installation window preference select 4th and 6th checkboxes (we need that only/ if you want ide – you can select […]
For example if you want to get value Box® from a style, <span style=”float: left;”Box®</span> <span style=”float: left;”Ball®</span> <span style=”float: left;”Bat®</span> String value =driver.findElement(By.xpath/use index or relative path).getCssValue(“left”);
import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class GetEbayLinks { public static WebDriver driver = null; public static void main(String[] args) { driver = new FirefoxDriver(); // going to ebay.com driver.get("http://ebay.com"); // getting the footer section box element WebElement sellLinks = driver.findElement(By .xpath(".//*[@id='gf-BIG']/table/tbody/tr/td[2]/ul")); // Listing elements from that footer box List<WebElement> […]
driver.findElement(By.id("alert")).click(); Alert alert = wait.until(alertIsPresent()); try { //trying to send keys values to a non existing an alert box. alert.sendKeys("hello"); } catch (ElementNotVisibleException e) { System.out.println(e.getMessage()); } finally { //finally handling the alert. alert.accept(); } }
Alert alert = wait.until(alertIsPresent()); alert.sendKeys("cheese"); alert.accept();
– Restart your cmd – Restart your eclipse. – Restart sikuli instances that is running on current user.