I have a vue.js app running at http://localhost:8080. I could view the application in normal browser but it is blank on JavaFX WebView. Please help me if you can.
public void start(Stage primaryStage) throws Exception {
WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
webEngine.setJavaScriptEnabled(true);
Scene scene = new Scene(browser);
primaryStage.setScene(scene);
primaryStage.show();
webEngine.load("http://localhost:8080");
}
Related
I am using Winium to automate a desktop application. The process is I download a file from the web and execute it. which opens the remote application. Till here everything is working fine, but I am unable to access any control of that newly launched remote Citrix application. Any help would be appreciated.
public void SetupEnv() throws InterruptedException
{
DesktopOptions options = new DesktopOptions();
options.setApplicationPath("C:\\Users\\ajinkya\\Downloads\\launch.ica");
try
{
driver = new WiniumDriver(new URL("http://localhost:9999"), options);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
Thread.sleep(5000);
driver.findElementByClassName("Transparent Windows Client").click();
Thread.sleep(5000);
}
Maybe you should try something like this:
WebElement window = driver.findElementByName("abcd.exe");
WebElement menuItem = window.findElement(By.name ("Find Item"));
menuItem.click();
I need to switch tabs using Graphene and continue the test without failing.
I am testing an application that creates a project and then opens that project from a link on a page.
My issue is that it opens the project in a new tab and to continue the test I have to switch to the new tab.
I am using the selenium switch windowHandler but getting an error from the Graphene. I will not know the new URL until the project has been created.
//Switch to tab opened from previous test
public void switchTab(int tabNumber) throws Exception{
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
Thread.sleep(3000);
}
}
Error: The page object 'CreateChangeSubProjStruct' that you are navigating to using either Graphene.goTo() or #InitialPage is not annotated with #Location
I can see the new page opens and is on top but the test is running on the original tab.
I have an MVC web application in development.
Currently to run my Selenium browser tests I have to right click on one of the views and choose "View In Browser". This initiates the web application and then I can run my browser tests.
Is there a way I can effectively "launch" the website as part of the setup() and teardown() of the test?
e.g.
[TestFixture]
public class MainNavigationTests
{
// here I have to predetermine the localhost port that Visual Studio uses
const string host = "http://localhost:57237/";
IWebDriver driver = new FirefoxDriver();
[Test]
public void canBrowseToHomePage()
{
driver.Url = host;
Assert.AreEqual("Index - My web app", driver.Title);
var homePageLink = driver.FindElement(By.ClassName("navbar-brand"));
homePageLink.Click();
Assert.IsTrue(driver.PageSource.Contains("The home page of the web app"));
}
}
Thanks.
I am new to Selenium and Arquillian framework. I am trying to implement Page Object Model. Webdriver browser capabilities are saved in arquillian xml file.
I am using TestNG and created the following classes:
public class Test{
#Drone
Webdriver driver;
#Page
Login login;
#Page
Home home;
public void createOrderTest(){
login.navigateURL();
login.setcredentials();
home.createOrder();
}
}
public class Login{
// Webelements needed in methods below are declared here
public void navigateURL(){
driver.get("//url/login.aspx");
}
public void setCredentials(){
// code to enter username, password and click login
Graphene.waitAjax().until().element(signIn).is().not().visible();
}
}
public class Home{
// Webelements needed in methods below are declared here
public void createOrder(){
// code to create order
}
}
Problem Statement:
I am not sure how to navigate between Login and Home pages in code. Once user logs in using Login page methods, how does Webdriver get to use Home page methods to continue the test ?
Error:
Test runs fine with navigateURL and setcredentials methods. However, test fails to access createOrder method as follows:
WARNING: Argument 1 for UpdateTestResultBeforeAfter.update is null. It won't be invoked.
FAILED CONFIGURATION: #BeforeMethod arquillianBeforeTest(public void Test.createOrder() throws javax.mail.MessagingException,java.io.IOException,java.security.GeneralSecurityException)
org.jboss.arquillian.graphene.enricher.exception.PageObjectInitializationException: Can not instantiate Page Object class Home
Please guide me. Thank you.
Is the home page a static page? I assume you should not redirect the login page to home page. This should be done by the application itself. That is, end user will access the login page with url. after the all the navigations should be done by the application itself.
#RunAsClient
public class Test extends Arquillian{
#Drone
Webdriver driver;
#Page
Login login;
#Page
Home home;
public void createOrderTest(){
login.navigateURL();
login.setcredentials();
//you do not need this
//home = Graphene.goTo(Home.class)
//use graphene fluent wait API to wait for the page load
home.createOrder();
}
}
I'm trying to debug some Selenium tests but I cannot reproduce the issue locally. On the CI, after selecting some check boxes, the page reloads (a loading animation is displayed), and on the Jenkins agent it hangs for hours. I tried using these options, which I've added in the class constructor of the page:
driver.manage().timeouts().implicitlyWait(8, SECONDS);
driver.manage().timeouts().pageLoadTimeout(8, SECONDS);
Also I tried
public static void waitForLoadingPopUpToBecomeInvisible() {
try {
WebdriverWait wait = new WebDriverWait(driver, 20);
wait.until(invisibilityOfElementLocated(By.className("loading")));
} catch (Exception e) {
driver.navigate().refresh()
}
}
I want to refresh the page if the loading animation is visible for more than X seconds, or to force kill the test if it has been running for more than Y minutes.
Can you please suggest any better ideas?