简体   繁体   English

在Eclipse中运行代码时,弹出窗口显示为“无法启动”

[英]popup is displayed as “Unable to launch” while running the code in Eclipse

I have tried the below code and while running the code I'm getting the popup as "The selection cannot be launched and there are no recent launches" 我已经尝试了以下代码,并且在运行代码时出现了以下弹出窗口:“无法启动选择,并且最近没有启动”

Can u please help me with this.... 你能帮我这个忙吗?

Thanks 谢谢

Full Code: 完整代码:

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Gmail_Login {

/**

    @param args

*/

public static void main(String[] args) {

// objects and variables instantiation

WebDriver driver = new FirefoxDriver();

String appUrl = "https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier";

// launch the firefox browser and open the application url

driver.get(appUrl);

// maximize the browser window

driver.manage().window().maximize();

// declare and initialize the variable to store the expected title of the webpage.

String expectedTitle = " Sign in - Google Accounts ";

// fetch the title of the web page and save it into a string variable

String actualTitle = driver.getTitle();

// compare the expected title of the page with the actual title of the page and print the result

if (expectedTitle.equals(actualTitle))

{

System.out.println("Verification Successful - The correct title is displayed on the web page.");

}

else

{

System.out.println("Verification Failed - An incorrect title is displayed on the web page.");

}

// enter a valid username in the email textbox

WebElement username = driver.findElement(By.id("Email"));

username.clear();

username.sendKeys("TestSelenium");

// enter a valid password in the password textbox

WebElement password = driver.findElement(By.id("Passwd"));

password.clear();

password.sendKeys("password123");

// click on the Sign in button

WebElement SignInButton = driver.findElement(By.id("signIn"));

SignInButton.click();

// close the web browser

driver.close();

System.out.println("Test script executed successfully.");

// terminate the program

System.exit(0);

}

}

I executed the code you shared. 我执行了您共享的代码。 It did not throw the error you mentioned. 它没有引发您提到的错误。 The only change I made to your code was setting System property webdriver.gecko.driver , as I am using the latest Selenium library and it require setting this path for using Firefox. 我对您的代码所做的唯一更改是设置系统属性webdriver.gecko.driver ,因为我正在使用最新的Selenium库,并且需要设置此路径才能使用Firefox。 I would recommend you as well to use the latest Selenium library . 我也建议您使用最新的Selenium You can download the geckodriver from here . 您可以从此处下载geckodriver

Before initializing the FirefoxDriver object, you need to set the relevant System property. 在初始化FirefoxDriver对象之前,您需要设置相关的System属性。 You can do that in following way: 您可以按照以下方式进行操作:

System.setProperty("webdriver.gecko.driver", "<path_to_geckodriver.exe>");
WebDriver driver = new FirefoxDriver();

Let me know, if you have any further queries. 让我知道,如果您还有其他疑问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM