-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration from CDP4J (via gradle multi-project)
- Loading branch information
1 parent
d5c222c
commit da50344
Showing
518 changed files
with
42,187 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '2.5.14' // Letzte Java-8-kompatible Version | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
id 'com.github.johnrengelman.shadow' version '8.1.1' // Um alles in JARs zu verpacken | ||
} | ||
|
||
group = 'selineer' // Package-Name | ||
version = '1.0.0' | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
dependencies { | ||
// Spring Boot Starter (Java 8 kompatibel) | ||
implementation 'org.springframework.boot:spring-boot-starter' | ||
|
||
// implementation 'org.java-websocket:Java-WebSocket:1.6.0' | ||
implementation 'org.java-websocket:Java-WebSocket:1.5.2' | ||
|
||
implementation 'com.google.code.gson:gson:2.8.9' | ||
|
||
implementation project(':cdp4j') // Abhängigkeit auf das cdp4j-Projekt | ||
|
||
// chrome_devtools_protocol | ||
// implementation 'org.netbeans.modules:org-netbeans-lib-chrome_devtools_protocol:RELEASE240' | ||
|
||
// // Chrome DevTools-Protokolls um WebDriver (verwendet Selenium) zu umgehen | ||
// implementation 'io.webfolder:cdp4j:4.8.4' | ||
// // Selenium WebDriver (Java 8 kompatibel) | ||
// implementation 'org.seleniumhq.selenium:selenium-java:3.141.59' | ||
|
||
// Optional: Lombok für weniger Boilerplate | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
// // Optional: Apache Commons Lang (nützliche Hilfsklassen) | ||
// implementation 'org.apache.commons:commons-lang3:3.12.0' | ||
|
||
// // Optional: Google Guava (nützliche Sammlungen und Werkzeuge) | ||
// implementation 'com.google.guava:guava:30.1.1-jre' | ||
|
||
// Optional: JUnit für Tests | ||
testImplementation 'junit:junit:4.13.2' | ||
} | ||
|
||
tasks.named('jar') { | ||
manifest { | ||
attributes( | ||
// Vermeide Aufrufkonventionen wie "java -cp o.jar selineer.Main" | ||
// Stattdessen: "java -jar o.jar" | ||
'Main-Class': 'selineer.app.Main' // Manifest-Eintrag | ||
) | ||
} | ||
} | ||
|
||
// Für Start mit Spring Boot: | ||
// tasks.named('bootJar') { | ||
// manifest { | ||
// attributes( | ||
// 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher' | ||
// ) | ||
// } | ||
// } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 74 additions & 0 deletions
74
adapter/src/main/java/selineer/service/BrowserConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package selineer.service; | ||
|
||
import io.webfolder.cdp.Launcher; | ||
import io.webfolder.cdp.session.SessionFactory; | ||
|
||
public class BrowserConnector { | ||
private SessionFactory sessionFactory; | ||
|
||
public void connectToBrowser(String host, int port) { | ||
try { | ||
// SessionFactory mit Host und Port initialisieren | ||
sessionFactory = new SessionFactory(host, port); | ||
|
||
// Verbindung testen: Sitzungen abrufen | ||
if (sessionFactory.list().isEmpty()) { | ||
throw new RuntimeException("Keine Sitzung gefunden. Verbindung fehlgeschlagen."); | ||
} | ||
|
||
System.out.println("Erfolgreich mit dem Browser verbunden!"); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException("Verbindung zum Browser fehlgeschlagen", e); | ||
} | ||
} | ||
|
||
public SessionFactory getSessionFactory() { | ||
return sessionFactory; | ||
} | ||
|
||
private String getWebSocketDebuggerUrl() { | ||
try { | ||
java.net.URL url = new java.net.URL("http://localhost:9222/json"); | ||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection(); | ||
connection.setRequestMethod("GET"); | ||
|
||
try (java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(connection.getInputStream()))) { | ||
StringBuilder response = new StringBuilder(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
response.append(line); | ||
} | ||
|
||
com.google.gson.JsonArray jsonArray = com.google.gson.JsonParser.parseString(response.toString()).getAsJsonArray(); | ||
if (jsonArray.size() > 0) { | ||
com.google.gson.JsonObject firstPage = jsonArray.get(0).getAsJsonObject(); | ||
return firstPage.get("webSocketDebuggerUrl").getAsString(); | ||
} | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
public void navigateToUrl(String url) { | ||
// Session explizit deklarieren | ||
io.webfolder.cdp.session.Session session = null; | ||
try { | ||
// Eine neue Sitzung erstellen | ||
session = sessionFactory.create(); | ||
session.navigate(url); | ||
session.waitDocumentReady(); // Warten, bis die Seite geladen ist | ||
System.out.println("Navigiert zu: " + url); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException("Navigation fehlgeschlagen", e); | ||
} finally { | ||
// Sitzung sicher schließen | ||
if (session != null) { | ||
session.close(); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,5 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '2.5.14' // Letzte Java-8-kompatible Version | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
} | ||
|
||
group = 'selineer' // Package-Name | ||
version = '1.0.0' | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// Spring Boot Starter (Java 8 kompatibel) | ||
implementation 'org.springframework.boot:spring-boot-starter' | ||
|
||
// implementation 'org.java-websocket:Java-WebSocket:1.6.0' | ||
implementation 'org.java-websocket:Java-WebSocket:1.5.2' | ||
|
||
implementation 'com.google.code.gson:gson:2.8.9' | ||
|
||
// chrome_devtools_protocol | ||
// implementation 'org.netbeans.modules:org-netbeans-lib-chrome_devtools_protocol:RELEASE240' | ||
|
||
// // Chrome DevTools-Protokolls um WebDriver (verwendet Selenium) zu umgehen | ||
// implementation 'io.webfolder:cdp4j:4.8.4' | ||
// // Selenium WebDriver (Java 8 kompatibel) | ||
// implementation 'org.seleniumhq.selenium:selenium-java:3.141.59' | ||
|
||
// Optional: Lombok für weniger Boilerplate | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
|
||
// // Optional: Apache Commons Lang (nützliche Hilfsklassen) | ||
// implementation 'org.apache.commons:commons-lang3:3.12.0' | ||
|
||
// // Optional: Google Guava (nützliche Sammlungen und Werkzeuge) | ||
// implementation 'com.google.guava:guava:30.1.1-jre' | ||
|
||
// Optional: JUnit für Tests | ||
testImplementation 'junit:junit:4.13.2' | ||
} | ||
|
||
tasks.named('jar') { | ||
manifest { | ||
attributes( | ||
// Vermeide Aufrufkonventionen wie "java -cp o.jar selineer.Main" | ||
// Stattdessen: "java -jar o.jar" | ||
'Main-Class': 'selineer.app.Main' // Manifest-Eintrag | ||
) | ||
allprojects { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
|
||
// Für Start mit Spring Boot: | ||
// tasks.named('bootJar') { | ||
// manifest { | ||
// attributes( | ||
// 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher' | ||
// ) | ||
// } | ||
// } | ||
} |
Oops, something went wrong.