简体   繁体   English

Java + Selenium + Chromedriver 获胜。 服务器 2012 R2

[英]Java + Selenium + Chromedriver on win. Server 2012 R2

I wrote an application in java using selenium and chromedriver which log-in to a website and then performs operations.我使用 selenium 和 chromedriver 在 java 中编写了一个应用程序,该应用程序登录到网站然后执行操作。 The application was developed on a windows server 2012 and I'm connecting to the server via RDP from my local machine.该应用程序是在 windows 服务器 2012 上开发的,我正在从本地计算机通过 RDP 连接到服务器。 When I'm logged on server, everything runs correctly (keeping the rdp connection active).当我登录服务器时,一切运行正常(保持 rdp 连接处于活动状态)。

The application is then started via a scheduled task in the windows task scheduler at regular intervals.然后通过 windows 任务调度程序中的计划任务定期启动应用程序。 The application is deployed on a payara server.该应用程序部署在 payara 服务器上。

The problem arises when I close the RDP session.当我关闭 RDP session 时出现问题。 The application is launched but in the payara console I notice that all the elements of the web page are not found, as if it were necessary to have the chrome window active.该应用程序已启动,但在 payara 控制台中,我注意到未找到 web 页面的所有元素,好像必须激活 chrome window。 I tried to use the headless mode (taking screenshots gradually) but for some reason I remain still at login (as if the headless mode was received by the target site), thus failing to login and the consequent execution of the operations.我尝试使用无头模式(逐渐截屏),但由于某种原因,我仍然处于登录状态(好像目标站点收到了无头模式),因此无法登录以及随后的操作执行。

Looking on the stacko.看着堆栈。 Forum, I found this thread that could probably solve the problem but it is not clear to me what the indicated script does.论坛,我发现这个线程可能可以解决问题,但我不清楚指示的脚本是做什么的。 LINK关联

The question I can't answer is: in order to correctly launch the application from the windows task scheduler without using the headless mode, is the RDP connection always active?我无法回答的问题是:为了在不使用无头模式的情况下从 windows 任务调度程序正确启动应用程序,RDP 连接是否始终处于活动状态? Or is it possible to start the software even though RDP is disconnected?或者即使 RDP 断开连接也可以启动软件?

Some technical details:一些技术细节:

  • ChromeDriver 88.0.4324.27 ChromeDriver 88.0.4324.27
  • ChromeBrowser 88.0.4324.190 (Official Build) ChromeBrowser 88.0.4324.190(官方版本)
  • JDK 11 JDK 11

Chrome Driver setup: Chrome 驱动设置:

System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("--disable-blink-features");
options.addArguments("--disable-blink-features=AutomationControlled");
options.addArguments("--no-sandbox");
options.addArguments("--disable-gpu");
options.setAcceptInsecureCerts(true);
options.addArguments("--start-maximized");
driver = new ChromeDriver(options);

Any suggestions are welcome.欢迎任何建议。 Thanks a lot in advance非常感谢提前

I am not sure it will help you or not.. You can enable RDP keep alive using registry我不确定它是否会对您有所帮助..您可以使用注册表启用 RDP 保持活动状态

Here you may get some idea https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.TerminalServer::TS_KEEP_ALIVE https://superuser.com/questions/1144853/how-do-i-keep-an-rdp-session-alive-from-the-client-side在这里你可能会有一些想法https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.TerminalServer::TS_KEEP_ALIVE https--548-34/do-i-keephow -session-alive-from-the-client-side

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

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