Selenium WebDriverを使用してテストフレームワークを作成しましたが、クロームブラウザを起動したいのですが、これはEclipseで同じように動作します。ジェンキンス経由で同じスクリプトを実行するには: -セレンスクリプトのジェンキンでクロムブラウザを開くことができません
エラー: -
T E S T S
-------------------------------------------------------
Running TestSuite
Starting ChromeDriver 2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf) on port 45706
Only local connections are allowed.
と、ブラウザを起動するために私のコードは次のとおりです。 -
public class BrowserSelection {
public static WebDriver driver;
public FileInputStream fis;
public static File file;
public static Properties prop;
public String username;
public String password;
public static XSSFWorkbook wb;
public static XSSFSheet ws;
public static WebDriverWait wait;
public static Screen src;
public static Pattern prn;
@BeforeSuite()
public void browser() throws Exception{
//property file load
prop=new Properties();
file=new File(System.getProperty("user.dir")+"\\src\\main\\resources\\config\\config.properties");
fis=new FileInputStream(file);
prop.load(fis);
//excel file load
fis=new FileInputStream(System.getProperty("user.dir")+"\\src\\main\\resources\\excel\\data.xlsx");
wb=new XSSFWorkbook(fis);
file=new File("D:\\LoyalityFiles\\");
//File[] dir_contents=file.listFiles();
if (prop.getProperty("browser").equalsIgnoreCase("firefox")) {
/*ProfilesIni profile=new ProfilesIni();
FirefoxProfile myprofile=profile.getProfile(prop.getProperty("firefoxprofilename"));*/
FirefoxProfile myprofile=new FirefoxProfile();
myprofile.setPreference("browser.download.dir",prop.getProperty("firefoxfilesave"));
myprofile.setPreference("browser.download.folderList", 2);
myprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/zip");
driver=new FirefoxDriver(myprofile);
}else if (prop.getProperty("browser").equalsIgnoreCase("chrome")) {
System.setProperty("Webdriver.chrome.driver",System.getProperty("user.dir")+prop.getProperty("chromeexe"));
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("download.default_directory", prop.getProperty("chromefileSave"));
DesiredCapabilities caps = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("--disable-extensions");
caps.setCapability(ChromeOptions.CAPABILITY, options);
driver=new ChromeDriver(caps);
}
driver.get(prop.getProperty("testURL"));
//driver.manage().window().maximize();
driver.manage().window().setSize(new Dimension(1366, 768));
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
*これは、Mavenのベースのプロジェクトです。
ジェンキンスはchrome exeパスを設定できないと思います。 plsは提案する!これを解決する方法.....
https://wiki.jenkins.io/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines+on+Windows?focusedCommentId=59510810 –