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

[BUG] Failed to create driver, Caused by: java.io.IOException: CreateProcess error=5, 拒绝访问。 #1256

Closed
xvjialing opened this issue Mar 30, 2023 · 2 comments
Labels

Comments

@xvjialing
Copy link

xvjialing commented Mar 30, 2023

System info

  • Playwright Version: [v1.32.0]
  • Operating System: [Windows 10]
  • Browser: [ Chromium]

Source code

import com.microsoft.playwright.*;
import com.microsoft.playwright.options.AriaRole;

public class Main {
    public static void main(String[] args) {
        try{
            Playwright playwright = Playwright.create();
            Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
            BrowserContext context = browser.newContext();
            Page page = context.newPage();
            page.navigate("https://xxx.xxxx.com");
            page.getByPlaceholder("请输入用户名称").click();
            page.getByPlaceholder("请输入用户名称").fill("test");
            page.getByPlaceholder("请输入用户名称").press("Tab");
            page.getByPlaceholder("请输入密码").fill("test");
            page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("登录")).click();
            page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("跳 过")).click();
            page.locator(".tooltip___1ZeIG > .anticon > svg > path").click();
            page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("图标: tablet 设备管理")).click();
            page.getByRole(AriaRole.TREEITEM, new Page.GetByRoleOptions().setName("图标: down-square 展会 (1) 图标: dash")).locator("span").nth(1).click();
            page.getByRole(AriaRole.TREEITEM, new Page.GetByRoleOptions().setName("图标: down-square 展会 (1) 图标: dash 展会 (2) 图标: dash")).getByRole(AriaRole.TREEITEM, new Locator.GetByRoleOptions().setName("展会 (2) 图标: dash")).getByText("展会").click();

            page.pause();
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}

Actual

Exception in thread "main" java.lang.RuntimeException: Failed to create driver
	at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:105)
	at com.microsoft.playwright.impl.driver.Driver.ensureDriverInstalled(Driver.java:57)
	at com.microsoft.playwright.impl.PlaywrightImpl.createImpl(PlaywrightImpl.java:45)
	at com.microsoft.playwright.impl.PlaywrightImpl.create(PlaywrightImpl.java:35)
	at com.microsoft.playwright.Playwright.create(Playwright.java:96)
	at com.microsoft.playwright.Playwright.create(Playwright.java:100)
	at com.langyangtech.iot.Main.main(Main.java:8)
Caused by: java.io.IOException: Cannot run program "C:\Users\QIAODI~1\AppData\Local\Temp\playwright-java-16425824829904964449\playwright.cmd": CreateProcess error=5, 拒绝访问。
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
	at com.microsoft.playwright.impl.driver.jar.DriverJar.installBrowsers(DriverJar.java:93)
	at com.microsoft.playwright.impl.driver.jar.DriverJar.initialize(DriverJar.java:69)
	at com.microsoft.playwright.impl.driver.Driver.initialize(Driver.java:64)
	at com.microsoft.playwright.impl.driver.Driver.createAndInstall(Driver.java:101)
	... 6 more
Caused by: java.io.IOException: CreateProcess error=5, 拒绝访问。
	at java.base/java.lang.ProcessImpl.create(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:492)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:153)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
	... 11 more

Question

The problem here may be that there is no C:\Users\QIAODI~1\AppData\Local\Temp\playwright-java-16425824829904964449\ permission to execute this directory, is there any way to change this path to a directory with permission to execute, such as in the root directory of the project code

@yury-s
Copy link
Member

yury-s commented Mar 30, 2023

You can specify alternative temp directory via playwright.driver.tmpdir system property. Either call System.setProperty("playwright.driver.tmpdir", tmpdir); before creating playwright instance or you can pass it as a maven command line option mvn ... -D playwright.driver.tmpdir="...". Will that work for you?

@mxschmitt
Copy link
Member

Closing as per above and since it looks stale.

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

No branches or pull requests

3 participants