Giter Club home page Giter Club logo

Comments (4)

tourdedave avatar tourdedave commented on July 29, 2024 1

Thanks! I'll take a look.

from elemental-selenium-tips.

tourdedave avatar tourdedave commented on July 29, 2024

If you're receiving that error than the jQuery Growl library isn't loading correctly during your test's browser session.

Can you provide your test code?

from elemental-selenium-tips.

MrRahulR avatar MrRahulR commented on July 29, 2024

I've copied and pasted the code provided on your project the differences are I used TestNG instead of JUnit there & Chrome instead of Firefox.
Below is the code.

package com.ratedr.growl;

import java.io.File;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class Growl {
	WebDriver driver;
	JavascriptExecutor js;

	@BeforeClass
	public void setUp() throws Exception {
		File file = new File(System.getProperty("user.dir") + "//chromedriver.exe");
		System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
		driver = new ChromeDriver();
		js = (JavascriptExecutor) driver;
	}

	@AfterClass
	public void tearDown() throws Exception {
		driver.quit();
	}

	@Test
	public void growlTest() throws InterruptedException {
		driver.get("http://the-internet.herokuapp.com/");

		// Check for jQuery on the page, add it if need be
		js.executeScript("if (!window.jQuery) {"
				+ "var jquery = document.createElement('script'); jquery.type = 'text/javascript';"
				+ "jquery.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js';"
				+ "document.getElementsByTagName('head')[0].appendChild(jquery);" + "}");

		// Use jQuery to add jquery-growl to the page
		js.executeScript("$.getScript('http://the-internet.herokuapp.com/js/vendor/jquery.growl.js')");

		// Use jQuery to add jquery-growl styles to the page
		js.executeScript("$('head').append('<link rel=\"stylesheet\" "
				+ "href=\"http://the-internet.herokuapp.com/css/jquery.growl.css\" " + "type=\"text/css\" />');");

		// jquery-growl w/ no frills
		js.executeScript("$.growl({ title: 'GET', message: '/' });");

		// jquery-growl w/ colorized output
		js.executeScript("$.growl.error({ title: 'ERROR', message: 'your error message goes here' });");
		js.executeScript("$.growl.notice({ title: 'Notice', message: 'your notice message goes here' });");
		js.executeScript("$.growl.warning({ title: 'Warning!', message: 'your warning message goes here' });");
		Thread.sleep(5000);
	}
}

from elemental-selenium-tips.

MrRahulR avatar MrRahulR commented on July 29, 2024

Hi @tourdedave ,
Anything you found in it?

from elemental-selenium-tips.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.