Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How htmlunit supports ES6 ? #767

Open
xuxiaowei-com-cn opened this issue Apr 8, 2024 · 2 comments
Open

How htmlunit supports ES6 ? #767

xuxiaowei-com-cn opened this issue Apr 8, 2024 · 2 comments

Comments

@xuxiaowei-com-cn
Copy link

The project I created using Vue/vite/TS cannot load external JS.

23:12:33.326 [main] DEBUG com.gargoylesoftware.htmlunit.util.EncodingSniffer - Encoding found in meta tag: 'UTF-8'.
23:12:33.328 [main] DEBUG com.gargoylesoftware.htmlunit.html.HtmlLink - Link node added: <link rel="icon" href="/favicon.ico"/>

23:12:33.328 [main] DEBUG com.gargoylesoftware.htmlunit.html.HtmlLink - Link type 'icon' not supported (<link rel="icon" href="/favicon.ico"/>).
23:12:33.332 [main] DEBUG com.gargoylesoftware.htmlunit.html.ScriptElementSupport - Script node added: <script type="module" lang="javascript" crossorigin="" src="/assets/index-DszroY3Z.js">
</script>

23:12:33.333 [main] DEBUG com.gargoylesoftware.htmlunit.html.ScriptElementSupport - Script is not JavaScript (type: 'module', language: ''). Skipping execution.
23:12:33.333 [main] DEBUG com.gargoylesoftware.htmlunit.html.HtmlLink - Link node added: <link rel="stylesheet" crossorigin="" href="/assets/index-C91cWaEe.css"/>

23:12:33.335 [main] DEBUG com.gargoylesoftware.htmlunit.WebClient - Load response for GET http://127.0.0.1:4173/assets/index-C91cWaEe.css
@xuxiaowei-com-cn
Copy link
Author

        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.60.0</version>
            <scope>test</scope>
        </dependency>
package cloud.xuxiaowei.passport.oauth;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@Slf4j
class AuthorizationCodeTests {

	@Test
	void start() throws IOException {
		try (WebClient webClient = new WebClient();) {
			webClient.getOptions().setJavaScriptEnabled(true);
			webClient.getOptions().setUseInsecureSSL(true);
			HtmlPage page = webClient.getPage("https://xxw.ac.cn");
			DomNode input = page.querySelector("input");
			assertNotNull(input);
		}
	}

}

@xuxiaowei-com-cn
Copy link
Author

        <dependency>
            <groupId>org.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>
package cloud.xuxiaowei.passport.oauth;

import lombok.extern.slf4j.Slf4j;
import org.htmlunit.WebClient;
import org.htmlunit.html.DomNode;
import org.htmlunit.html.HtmlPage;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@Slf4j
class AuthorizationCodeTests {

	@Test
	void start() throws IOException {
		try (WebClient webClient = new WebClient();) {
			webClient.getOptions().setJavaScriptEnabled(true);
			webClient.getOptions().setUseInsecureSSL(true);
			HtmlPage page = webClient.getPage("https://xxw.ac.cn");
			DomNode input = page.querySelector("input");
			assertNotNull(input);
		}
	}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant