import { NgModule } from '#angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { Ng2SearchPipeModule } from 'ng2-search-filter';
#NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
Ng2SearchPipeModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
IntelliJ is giving me the message " Class Ng2SearchPipeModule is not an Angular module ". Is there a way to fix this?
Check Ng2SearchPipeModule to have proper decorator. It has to be NgModule like your app module has.
#NgModule({
declarations: [
...
],
imports: [
...
],
providers: [],
})
export class Ng2SearchPipeModule { }
Also, check if the import path is correct
Selenium grid test case failed in headless browser mode only
Normal Browser Mode [Test Success]
selenium stand alone server : 3.0.1
Firefox : 38.0.1
ip : 192.168.1.40
Headless Browser Mode [Test Failed]
selenium stand alone server : 3.0.1
Firefox : 38.0
ip : 172.18.0.60
I run headless browser like below
xvfb-run java -Dwebdriver.firefox.marionette="/tmp/geckodriver" -Dwebdriver.firefox.bin="/tmp/firefox/firefox" -jar selenium-server-standalone-3.0.1.jar -role webdriver -hub http://192.168.1.106:4444/grid/register -port 5566 -host 172.18.0.60
Test Case Code:
package example;
import org.junit.Assert;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.net.MalformedURLException;
public class NewTest
{
public WebDriver driver;
public String URL, Node;
private JavascriptExecutor jse;
private String baseUrl;
protected ThreadLocal<RemoteWebDriver> threadDriver = null;
#Parameters({"browser","url"})
#BeforeTest
public void launchapp(String browser,String url) throws MalformedURLException
{
baseUrl = "http://myhost";
if (browser.equalsIgnoreCase("firefox"))
{
System.out.println(" Executing on FireFox");
String Node = url;
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
driver = new RemoteWebDriver(new URL(Node), cap);
// Puts an Implicit wait, Will wait for 10 seconds before throwing exception
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
// Launch website
driver.navigate().to(baseUrl);
driver.manage().window().maximize();
}
else
{
throw new IllegalArgumentException("The Browser Type is Undefined");
}
jse = (JavascriptExecutor)driver;
}
#Test
public void functionalityTest() throws InterruptedException
{
driver.findElement(By.linkText("Sign In")).click();
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("xxxxx#xxx.xxx");
driver.findElement(By.id("pass")).clear();
driver.findElement(By.id("pass")).sendKeys("xxxxxx");
driver.findElement(By.id("send2")).click();
jse.executeScript("scroll(0, 250);");
driver.findElement(By.cssSelector(".customerlink a")).click();
Thread.sleep(1000);
driver.findElement(By.linkText("My Account")).click();
Thread.sleep(2000);
jse.executeScript("scroll(0, 250);");
Thread.sleep(1000);
jse.executeScript("scroll(0, -250);");
Thread.sleep(2000);
driver.findElement(By.cssSelector(".customerlink a")).click();
Thread.sleep(1000);
driver.findElement(By.linkText("Sign Out")).click();
Thread.sleep(2000);
}
#AfterTest
public void closeBrowser()
{
driver.quit();
}
}
I got exception in very first line of headless brwoser mode
07:16:53.571 INFO - Executing: [new session: Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}]])
07:16:53.580 INFO - Creating a new session for Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}]
07:17:00.268 INFO - Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
07:17:02.648 INFO - Detected dialect: OSS
07:17:02.665 INFO - Done: [new session: Capabilities [{marionette=true, firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#3e74110c, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#3e74110c, version=, platform=ANY}]]
07:17:02.701 INFO - Executing: [implicit wait: 50000])
07:17:02.717 INFO - Done: [implicit wait: 50000]
07:17:02.724 INFO - Executing: [get: http://myhost])
07:18:03.564 INFO - Done: [get: http://myhost]
07:18:03.570 INFO - Executing: [maximise window])
07:18:03.580 INFO - Done: [maximise window]
07:18:03.593 INFO - Executing: [find element: By.linkText: Sign In])
07:18:53.917 WARN - Exception thrown
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"link text","selector":"Sign In"}
like
The error state clearly unable to locate element but how it worked in normal mode?
Is there any restriction in code to use headless browser mode?
Finally found, Headless browser does not take account of driver.manage().window().maximize(); so I set screen size through xvfb-run command
-s "-screen 0, 1920x1080x24"
Example:
xvfb-run -s "-screen 0, 1920x1080x24" java -Dwebdriver.firefox.marionette="/tmp/geckodriver" -Dwebdriver.firefox.bin="/tmp/firefox/firefox" -jar selenium-server-standalone-3.0.1.jar -role webdriver -hub http://192.168.1.106:4444/grid/register -port 5566 -host 172.18.0.60
Info: I'm using bootstrap so visible of element to be changed according to the screensize. So it will throw element not found exeception
I am coding in java and to implement persistence for my game model and players I was hoping to create and use a mongo database. I am not using any authentication, but mongodb is throwing an error that insists that I am not authorized to do anything.
What would cause the program to think that authentication is necessary and how can I fix this?
Exception in thread "main" com.mongodb.MongoCommandException:
Command failed with error 13:
'not authorized on Catan2 to execute command
{
insert: "Players",
ordered: true,
documents: [ { _id: 20, Login: "{"username":"un","password":"p","ID":20}" } ]
}'
on server 127.0.0.1:27017.
The full response is
{
"ok" : 0.0,
"errmsg" : "not authorized on Catan2 to execute command
{
insert: \"Players\",
ordered: true,
documents: [ { _id: 20, Login: \"{\"username\":\"un\",\"password\":\"p\",\"ID\":20}\" } ]
}",
"code" : 13 }
I have included my code below to show the steps that I am taking.
import server.plugincode.iplugin.IPersistencePlugin;
import server.plugincode.iplugin.IPlayerDAO;
import com.mongodb.DB;
import com.mongodb.MongoClient;
import shared.jsonobject.Login;
import org.bson.Document;
import com.google.gson.GsonBuilder;
import com.mongodb.client.MongoDatabase;
public class MongoPersistencePlugin implements IPersistencePlugin {
private MongoClient mongoClient;
private PlayerDAO Players;
private DB mdb;
public MongoPersistencePlugin()
{
mongoClient = new MongoClient();
MongoDatabase mdb = mongoClient.getDatabase("Catan2");
GsonBuilder gson = new GsonBuilder();
gson.enableComplexMapKeySerialization();
String info = gson.create().toJson(new Login("un", "p", 20));
Document test = new Document("_id", 20).append("Login", info);
mdb.getCollection("Players").insertOne(test);
mdb.getCollection("Players").drop();
Players = new PlayerDAO(mdb);
// Games = new GameDAO(mdb);
// Commands = new CommandDAO(mdb);
// clear();
}
}
I am using Mongodb 3.0, Java 8 and am working on a Windows laptop if that helps.
Actually I am trying to parse schema.org Microdata from HTML source pages using a java library.I tried many sites finally I found any23 and Mf2j from github For .apache any23 I didn't find proper documentation so I left that and finally using Mf2j I build the project and I got the jar. I created a sample project to execute Mf2j to parse Microdata. Here is the sample code which I wrote.
package org.mypro;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;
import com.kylewm.mf2j.Mf2Parser;
public class MySample {
/**
* #param args
* #throws URISyntaxException
* #throws IOException
*/
public static void main(String[] args) throws IOException, URISyntaxException {
// TODO Auto-generated method stub
Mf2Parser parser = new Mf2Parser()
.setIncludeAlternates(true)
.setIncludeRelUrls(true);
URL server = new URL("http://blogbasics.com/examples-of-blogs/");
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost","pp.xyz.com");
systemProperties.setProperty("http.proxyPort","1234");
HttpURLConnection connection = (HttpURLConnection)server.openConnection();
connection.connect();
Map<String,Object> parsed = parser.parse(new URI("http://blogbasics.com/examples-of-blogs/"));
for (Entry<String, Object> string : parsed.entrySet()) {
System.out.println(string.getKey() +" = "+string.getValue());
}
}
}
But I got output like this. I got ly image URL's but I need all Microdata metadata.
rels = {"Icon":["http://blogbasics.com/wp-content/uploads/cropped-Blog-Basics-favicon.png"],"Shortcut":["http://blogbasics.com/wp-content/uploads/cropped-Blog-Basics-favicon.png"],"apple-touch-icon-precomposed":["http://blogbasics.com/wp-content/uploads/apple-touch-icon-144x144.png","http://blogbasics.com/wp-content/uploads/apple-touch-icon-114x114.png","http://blogbasics.com/wp-content/uploads/apple-touch-icon-72x72.png","http://blogbasics.com/wp-content/uploads/apple-touch-icon-57x57.png"],"canonical":["http://blogbasics.com/examples-of-blogs/"],"external":["http://blogbasics.com","http://allisondduncan.com","http://www.kuldipsonsjewellers.com/Earring.html","http://jin6000.tumblr.com/","http://ckckarate.com","http://www.ferrypress.com/profile.php?u=Herman1879"],"nofollow":["http://bit.ly/1EQF6HG","https://curlcentric.leadpages.net/leadbox/14581e773f72a2%3A12e927026b46dc/5758142528880640/","http://blogbasics.com/examples-of-blogs/#comment-261","http://blogbasics.com","http://blogbasics.com/examples-of-blogs/#comment-262","http://allisondduncan.com","http://blogbasics.com/examples-of-blogs/#comment-270","http://blogbasics.com/examples-of-blogs/#comment-736","http://www.kuldipsonsjewellers.com/Earring.html","http://blogbasics.com/examples-of-blogs/#comment-1407","http://blogbasics.com/examples-of-blogs/#comment-3036","http://blogbasics.com/examples-of-blogs/#comment-5682","http://blogbasics.com/examples-of-blogs/#comment-6877","http://blogbasics.com/examples-of-blogs/#comment-8615","http://jin6000.tumblr.com/","http://blogbasics.com/examples-of-blogs/#comment-8684","http://ckckarate.com","http://blogbasics.com/examples-of-blogs/#comment-18326","http://www.ferrypress.com/profile.php?u=Herman1879","http://blogbasics.com/examples-of-blogs/#comment-22883","http://blogbasics.com/examples-of-blogs/#comment-26672","http://blogbasics.com/examples-of-blogs/#respond","http://www.blogbasics.com","http://www.blogbasics.com/privacy","http://www.blogbasics.com/terms-conditions/","http://www.blogbasics.com/contact/"],"publisher":["https://www.google.com/+Blogbasics"],"stylesheet":["http://blogbasics.com/wp-content/themes/tru/style.css?v=1427736009&ver=2.1.3","http://fonts.googleapis.com/css?family=Open+Sans%3A300%2C400italic%2C400%2C600%2C700%7CRokkitt&ver=1.5","http://optinskin.com/src-4/min/normalize.min.css?ver=4.3","http://blogbasics.com/wp-content/plugins/OptinSkin/skins/1/style.css?ver=4.3","http://blogbasics.com/wp-content/themes/tru/includes/lib/spyr_slidingshare/style.css?ver=0.9.3"]}
items = []
rel-urls = {"http://allisondduncan.com":{"rels":["external","nofollow"],"text":"Allison Duncan"},"http://bit.ly/1EQF6HG":{"rels":["nofollow"]},"http://blogbasics.com":{"rels":["external","nofollow"],"text":"Paul Odtaa"},"http://blogbasics.com/examples-of-blogs/":{"rels":["canonical"]},"http://blogbasics.com/examples-of-blogs/#comment-1407":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-18326":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-22883":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-261":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-262":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-26672":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-270":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-3036":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-5682":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-6877":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-736":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-8615":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#comment-8684":{"rels":["nofollow"],"text":"Reply"},"http://blogbasics.com/examples-of-blogs/#respond":{"rels":["nofollow"],"text":"Cancel reply"},"http://blogbasics.com/wp-content/plugins/OptinSkin/skins/1/style.css?ver=4.3":{"media":"all","rels":["stylesheet"],"type":"text/css"},"http://blogbasics.com/wp-content/themes/tru/includes/lib/spyr_slidingshare/style.css?ver=0.9.3":{"media":"all","rels":["stylesheet"],"type":"text/css"},"http://blogbasics.com/wp-content/themes/tru/style.css?v=1427736009&ver=2.1.3":{"media":"all","rels":["stylesheet"],"type":"text/css"},"http://blogbasics.com/wp-content/uploads/apple-touch-icon-114x114.png":{"rels":["apple-touch-icon-precomposed"]},"http://blogbasics.com/wp-content/uploads/apple-touch-icon-144x144.png":{"rels":["apple-touch-icon-precomposed"]},"http://blogbasics.com/wp-content/uploads/apple-touch-icon-57x57.png":{"rels":["apple-touch-icon-precomposed"]},"http://blogbasics.com/wp-content/uploads/apple-touch-icon-72x72.png":{"rels":["apple-touch-icon-precomposed"]},"http://blogbasics.com/wp-content/uploads/cropped-Blog-Basics-favicon.png":{"rels":["Shortcut","Icon"],"type":"image/x-icon"},"http://ckckarate.com":{"rels":["external","nofollow"],"text":"Ed JP"},"http://fonts.googleapis.com/css?family=Open+Sans%3A300%2C400italic%2C400%2C600%2C700%7CRokkitt&ver=1.5":{"media":"all","rels":["stylesheet"],"type":"text/css"},"http://jin6000.tumblr.com/":{"rels":["external","nofollow"],"text":"Edward Carty"},"http://optinskin.com/src-4/min/normalize.min.css?ver=4.3":{"media":"all","rels":["stylesheet"],"type":"text/css"},"http://www.blogbasics.com":{"rels":["nofollow"],"text":"Blog Basics"},"http://www.blogbasics.com/contact/":{"rels":["nofollow"],"text":"Contact"},"http://www.blogbasics.com/privacy":{"rels":["nofollow"],"text":"Privacy Policy"},"http://www.blogbasics.com/terms-conditions/":{"rels":["nofollow"],"text":"Terms and Conditions"},"http://www.ferrypress.com/profile.php?u=Herman1879":{"rels":["external","nofollow"],"text":"hgh xl"},"http://www.kuldipsonsjewellers.com/Earring.html":{"rels":["external","nofollow"],"text":"Jewellery Shop in Ranchi"},"https://curlcentric.leadpages.net/leadbox/14581e773f72a2%3A12e927026b46dc/5758142528880640/":{"rels":["nofollow"],"text":"(Click Here)"},"https://www.google.com/+Blogbasics":{"rels":["publisher"]}}
Actually I need output in this form, not in json format. I need data content like this. I found this using JavaScript Microdata Parser from http://foolip.org/microdatajs/live/ but I need same kind of parser in java. Please suggest me. Thanks
"type": [ "http://schema.org/WebPage" ], "properties": { "mainContentOfPage": [ { "type": [ "http://schema.org/Blog" ], "properties": { "blogPost": [ { "type": [ "http://schema.org/BlogPosting" ], "properties": { "headline": [ "Examples of Blogs" ], "author": [ { "type": [ "http://schema.org/Person" ], "properties": { "name": [ "Kenneth Byrd" ] } } ],
Read more: http://foolip.org/microdatajs/live/#ixzz3lJJII7g0
I am trying to run a test using testng via selenium grid.
these tests worked previously, but today, i am getting this error:
The path to the driver executable must be set by the webdriver.ie.driver system property
That error does not make sense because my test is supposed to be running on firefox.
Here's the bits....
TESTNG
<test name="Run using Firefox 25 on Windows 7">
<parameter name="GridBrowser" value="firefox25win7"/>
<classes>
<class name="com.coursestrand_courseoverviewpanel.CourseOverviewPanelTest"/>
</classes>
</test>
CODE SNIPPET FOR ABOVE VALUE
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Configuration {
public static DesiredCapabilities setCap;
public static final String GRID_HUB_URL = "http://192.168.53.67:4444/wd/hub";
public static String SeleniumGridSetup(String gridBrowser) {
String newGridBrowser = gridBrowser;
switch (newGridBrowser) {
case "firefox25win7":
System.out.println("Firefox Version 25.0 on Windows 7");
setCap= DesiredCapabilities.firefox();
setCap.setBrowserName("firefox25win7");
setCap.setPlatform(org.openqa.selenium.Platform.WINDOWS);
break;
}
return newGridBrowser;
}
HERE'S MY TEST
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.*;
import com.environments.Configuration;
import com.thoughtworks.twist.core.execution.TwistScenarioDataStore;
import org.openqa.selenium.firefox.*;
import org.testng.Assert;
public class CourseOverviewPanelTest {
public WebDriver browser;
public static String url;
#Autowired
private TwistScenarioDataStore scenarioStore;
#Parameters({"GridBrowser"})
public CourseOverviewPanelTest(String GridBrowser) throws Exception {
Configuration.SeleniumGridSetup(GridBrowser);
browser = new RemoteWebDriver(new URL(Configuration.GRID_HUB_URL), Configuration.setCap);
url = Configuration.getUrl();
browser.manage().window().maximize();
browser.navigate().to(url + "/course-list.html");
}
public CourseOverviewPanelTest() throws Exception {
browser = new FirefoxDriver();
browser.manage().window().maximize();
url = Configuration.getUrl();
browser.navigate().to(url + "/course-list.html");
}
// Test methods start from here for Landing page carousel
#Test
public void displayCourseTitleAndDescription() throws Exception {
final String courseTitle = browser.findElement(By.xpath("/html/body/section/section/article/ul/li[1]/h4")).getText();
Assert.assertEquals("Maths", courseTitle);
}
SELENIUM GRID NODE
java -jar selenium-server-standalone-2.39.0.jar -role webdriver -hub http://192.168.53.67:4444/grid/register -browser browserName="firefox25win7",platform=WINDOWS -port 5585
THIS IS THE CONFIG CREATED IN GRID WHEN FIREFOX NODE IS RUN
role:webdriver
remoteHost:http://192.168.53.70:5585
hubHost:192.168.53.67
hubPort:4444
prioritizer:null
timeout:300000
throwOnCapabilityNotPresent:true
nodePolling:5000
url:http://192.168.53.70:5585
newSessionWaitTimeout:-1
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
cleanUpCycle:5000
hub:http://192.168.53.67:4444/grid/register
port:5585
browser:browserName=firefox25win7,platform=WINDOWS
browserTimeout:0
host:192.168.53.70
servlets:[]
maxSession:5
registerCycle:5000
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
register:true
When I execute the testng test, the error is returning in the console.
Note:
If I do set the path to the executable driver (in the node), then the test runs in IE!
FURTHER NOTE:
The issue also occurs when I run my chrome node, which looks like this:
java -Dwebdriver.chrome.driver=C:/selenium-server/chromedriver.exe -jar selenium-server-standalone-2.39.0.jar -role webdriver -hub http://192.168.53.67:4444/grid/register -port 5566 -browser browserName="chromeLatestWindows7",platform=WINDOWS
The crazy thing is if i change -Dwebdriver.chrome.driver=C:/selenium-server/chromedriver.exe in the above node to
-Dwebdriver.ie.driver=C:/selenium-server/chromedriver.exe then my test runs fine in chrome!!
The issue seems to be with the browsername. As per documentation the allowed values are "Parameters allowed for -browser: browserName={android, chrome, firefox, htmlunit, internet explorer, iphone, opera}". Change the name of firefox25win7 to firefox and it should work.