Я пробую селен.
Отлично работает в вашей локальной среде, но только на серверах Linux
Spit NoSuchException.
Не думаю, что стоит ждать.
Я тоже не думаю, что это проблема без головы.
Кто-нибудь прошел через эту проблему и решил ее?
это код ошибки в консоли
`org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"name","selector":"userid"}
(Session info: headless chrome=70.0.3538.67)
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 3.10.0-862.3.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'ip-172-31-28-49.ap-northeast-2.compute.internal', ip: '172.31.28.49', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.3.2.el7.x86_64', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.40.565383 (76257d1ab79276..., userDataDir: /tmp/.org.chromium.Chromium...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 70.0.3538.67, webStorageEnabled: true}
Session ID: 34195ae01936aaa26e70d614f95af840
*** Element info: {Using=name, value=userid}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:449)
at org.openqa.selenium.By$ByName.findElement(By.java:303)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at com.tmc.hotelpkg.HotelpkgLogin.loginHotelpkgLogin(HotelpkgLogin.java:24)
at com.tmc.hotelpkg.HotelpkgService.getReservation(HotelpkgService.java:90)
at com.tmc.schedule.DoBatch.batchHotelTimeGetReservation(DoBatch.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
1851ms
`
System.out.println (webDriver.getPageSource ()); это локальный результат
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="ko" class="wf-loading wf-notosanskr-n4-loading"><head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex,nofollow" />
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<![endif]-->
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/css/bootstrap.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="/css/style.css?ver=170912" />
<link rel="shortcut icon" type="image/x-icon" href="https://img.hotelpkg.com/favicon.ico" />
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" type="text/javascript" async=""></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<script src="/js/common.js"></script>
<script src="https://img.hotelpkg.com/js/moment.min.js"></script>
<script src="https://img.hotelpkg.com/js/jquery.popupwindow.js"></script>
<script>
WebFontConfig = {
custom: {
families: ['Noto Sans KR'],
urls: ['https://fonts.googleapis.com/earlyaccess/notosanskr.css']
}
};
(function() {
var wf = document.createElement('script');
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/earlyaccess/notosanskr.css" media="all" />
</head>
<body>
<link rel="stylesheet" href="/css/login.css?ver=170912" />
<div class="container-fluid">
<form method="post" class="form-signin">
<h4 class="form-signin-heading"></h4>
<label for="userid" class="sr-only">아이디</label>
<input type="text" name="userid" id="userid" class="form-control" placeholder="아이디" maxlength="24" required="" autofocus="" />
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" name="userpw" id="userpw" class="form-control" placeholder="패스워드" maxlength="60" required="" />
<button class="btn btn-lg btn-primary btn-block" type="submit">로그인</button>
<input type="hidden" name="url" value="" />
<input type="hidden" name="act" value="login" />
</form>
</div>
</body></html>
System.out.println (webDriver.getPageSource ()); это результат сервера
<code>`<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta charset="utf-8" />
<meta name="robots" content="noindex,nofollow" />
<title>403 Forbidden</title>
<style type="text/css">
html {background-color: #eee; font-family: sans-serif}
body {background-color: #fff; border: 1px solid #ddd; padding: 15px; margin: 15px}
h1 {font-family: serif}
pre {background-color: #eee; border: 1px solid #ddd; padding: 5px}
</style>
</head>
<body>
<h1>Error: 403 Forbidden</h1>
<p>You don't have permission to access on <tt>"/"</tt> this server.</p>
<pre>Nothing to see here..
`