小编sri*_*tas的帖子

如何在nodejs中裁剪屏幕截图或图像(.png)?

  1. 考虑一个图像文件 .png
  2. 假设您有某些元素的 xy 线,例如 x:400、y:500
  3. 假设您有要裁剪的图像大小:宽度:50,高度:20

我有以下来自nodejs pack easyimage 的片段,并且我也安装了ImageMagick。 当我运行下面的代码时,它只是通过但无法裁剪图像。

easyimage.crop(
  {
    src: "F:/screenshot.png",  // Contains fullscreen image
    dst: "F:/screenshot.png",  // New image with cropped name
    x: 400,
    y: 500,
    cropwidth: 50,
    cropheight: 20,
    gravity: "North-West",
  },
  (err, stdout, stderr) => {
    if (err) throw err
  }
)
Run Code Online (Sandbox Code Playgroud)

javascript imagemagick image-processing node.js easyimage

9
推荐指数
1
解决办法
1万
查看次数

安装Jenkins插件时出现“服务器返回的HTTP响应代码:403”错误

尝试为Jenkins安装插件时,看到以下错误。

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\tech>cd C:\Program Files (x86)\Jenkins

C:\Program Files (x86)\Jenkins>java -jar jenkins-cli.jar -s http://localhost:8081/ install-plugin ant.hpi -deploy -restart

Exception in thread "main" java.io.IOException: No X-Jenkins-CLI2-Port among [null, X-Required-Permission, X-Jenkins,
X-You-Are-In-Group, X-Hudson, Content-Length, Expires, X-You-Are-Authenticated-As, X-Permission-Implied-By, Set-Cookie,
Server, X-Content-Type-Options, Date, X-Jenkins-Session, Content-Type]
        at hudson.cli.CLI.getCliTcpPort(CLI.java:290)
        at hudson.cli.CLI.<init>(CLI.java:133)
        at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
        at hudson.cli.CLI._main(CLI.java:474)
        at hudson.cli.CLI.main(CLI.java:389)
        Suppressed: java.io.IOException: Server returned HTTP response code: 403 for URL: http://localhost:8081/cli
                at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
                at hudson.cli.FullDuplexHttpStream.<init>(FullDuplexHttpStream.java:78)
                at hudson.cli.CLI.connectViaHttp(CLI.java:163)
                at hudson.cli.CLI.<init>(CLI.java:137) …
Run Code Online (Sandbox Code Playgroud)

ant cmd jenkins jenkins-plugins

2
推荐指数
1
解决办法
6075
查看次数

有没有办法先在主窗口上搜索 webelement,如果没有找到,然后开始在 iframe 中搜索?

要求:默认情况下,在主窗口搜索 webelement,如果找到则执行操作,否则在 iframes 中搜索 webelement 并执行所需的操作

硒 3.141

'''
WebElement el = driver.findElement(By.xpath("//*[contains(text(),'here')]"));
    boolean displayFlag = el.isDisplayed();
    if(displayFlag == true)
    {
    sysout("element available in main window")  
    el.click();
    }
    else 
    {
      for(int f=0;f<10;f++)
      {
          sysout("element available in frameset")  
          switchToFrame(frameName[f]);
          el.click();
          System.out.println("Webelement not displayed");
      }
    }
'''
Run Code Online (Sandbox Code Playgroud)

我的脚本在第一行本身就失败了。它试图在主窗口中查找元素,但元素实际上在 iframe 中可用。

但要求是先在主窗口中搜索,然后才导航到 iframe。如何处理这样的用例?

有什么建议会有所帮助吗?谢谢你。

java selenium selenium-webdriver

0
推荐指数
1
解决办法
415
查看次数