GVKun编程网logo

在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载

2

在这篇文章中,我们将为您详细介绍在RobotFramework中,页面未在ubuntu:18.04的无头chrome中完全加载的内容。此外,我们还会涉及一些关于Chrome扩展-如何使用manifes

在这篇文章中,我们将为您详细介绍在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载的内容。此外,我们还会涉及一些关于Chrome 扩展 - 如何使用 manifest v3 访问本地 file:// 解决方法:文件系统 API,Chrome 88-90解决方案 1. 扩展框架,Chrome 91+解决方案 2. 扩展窗口/选项卡,Chrome 91+注意事项、Express:页面未在 res.redirect() 上更新我必须手动重新加载页面才能看到更改如何解决这个问题?、Google chrome 和 chrome webdriver 安装在 Ubuntu 中,但仍然 driver = webdriver.Chrome('/usr/bin/chromedriver') 失败、install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd的知识,以帮助您更全面地了解这个主题。

本文目录一览:

在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载

在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载

如何解决在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载

关于测试中的 Web 应用程序: 应用程序是使用 Angular JS 和 React 开发的。

问题: 从主页使用 Robot Framework,导航到其他页面。页面部分加载,部分组件未加载。(页面使用 angular 和 react 代码开发

使用的设置: 下面的 chrome 选项 用于启动浏览器

  1. Call Method ${chrome options} add_argument --headless
  2. Call Method ${chrome options} add_argument --start-maximized
  3. Call Method ${chrome options} add_argument --no-sandBox
  4. Call Method ${chrome_options} add_argument --disable-dev-shm-usage

使用的版本:

  • ubuntu:18.04
  • Python 3.6.9
  • robotframework-4.0
  • robotframework-selenium2library-3.0.0
  • gitlab 13.10

注意: 有了以上设置,Windows 机器上的 Headless 和 GUI 都可以工作,只有 CI/CD 不工作

这里有没有人遇到过同样的问题,请帮忙解决这个问题?谢谢!

解决方法

我相信这是因为您使用的是旧版本的 Selenium 库,如果是 5.1.3,则是当前最新版本。尝试安装最新版本

  1. pip install --upgrade robotframework-seleniumlibrary

  1. pip install --upgrade robotframework-selenium2library

然后更新您的浏览器和浏览器驱动程序。

Chrome 扩展 - 如何使用 manifest v3 访问本地 file:// 解决方法:文件系统 API,Chrome 88-90解决方案 1. 扩展框架,Chrome 91+解决方案 2. 扩展窗口/选项卡,Chrome 91+注意事项

Chrome 扩展 - 如何使用 manifest v3 访问本地 file:// 解决方法:文件系统 API,Chrome 88-90解决方案 1. 扩展框架,Chrome 91+解决方案 2. 扩展窗口/选项卡,Chrome 91+注意事项

如何解决Chrome 扩展 - 如何使用 manifest v3 访问本地 file:// 解决方法:文件系统 API,Chrome 88-90解决方案 1. 扩展框架,Chrome 91+解决方案 2. 扩展窗口/选项卡,Chrome 91+注意事项

我有一个 Chrome 扩展程序,它可以(如果您允许访问文件 URL)抓取您在 chrome 中打开的本地 pdf 文件,并将其发送到我们的 API 进行处理。这是通过从后台脚本中获取带有 XMLHttpRequestfile:///Users/user/whatever/testfile.pdf 的 pdf 来完成的。

当为 Chrome 扩展程序迁移到 manifest v3 时,后台脚本将成为服务工作者。在 Service Worker 中,只有 fetch 可用,而不是 XMLHttpRequest。问题是,fetch 只支持 http 和 https,不支持 file:// url。那么,我如何才能实现让 Chrome 扩展程序获取/获取本地文件的相同功能?

编辑:我也尝试过的事情:

  1. 按照回答的建议从注入的 iframe 中创建 XMLHttpRequest。 发出请求时会出现错误 net:ERR_UNKNowN_URL_SCHEME

    net:ERR_UNKNOWN_URL_SCHEME

  2. 从注入的内容脚本生成 XMLHttpRequest。 这给出了错误 Access to XMLHttpRequest at ''file:///.../testfile1.docx.pdf'' from origin ''null'' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http,data,chrome,chrome-extension,chrome-untrusted,https.

    Access to XMLHttpRequest at ''file:///Users/clara.attermo/Downloads/testfile1.docx.pdf'' from origin ''null'' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http,https.

据我从大量研究中了解到,对 file:// 的访问通常被阻止,Chrome 扩展程序后台脚本曾经是一个例外。在我看来,内容脚本或操作弹出窗口从未允许这样做。

我的 manifest.json 供参考:

{
  "manifest_version": 3,"name": "..","version": "0.1","icons": {
    "16": "assets/icon-16x16.png","48": "assets/icon-48x48.png","128": "assets/icon-128x128.png"
  },"action": {
    "default_title": ".."
  },"background": {
    "service_worker": "background.js"
  },"permissions": [
    "webRequest","activeTab","scripting","storage","unlimitedStorage","identity","pageCapture"
  ],"host_permissions": [
    "<all_urls>"
  ],"web_accessible_resources": [{
    "resources": ["iframe.html"],"matches": [],"extension_ids": []
  }]
}

以编程方式注入内容脚本(使用 webextension-polyfill 进行 promise 支持)

browser.action.onClicked.addListener(async (tab: Tab) => {
  await browser.scripting.executeScript({files: [ "inject.js" ],target: {tabId: tab.id}});
});

解决方法

由于您已经提到的原因,您无法在后台 Service Worker 中执行此操作。还有一个 bug 阻止在正常可见的 chrome-extension:// 页面或 iframe 中执行此操作。它已在 Chrome 91 中修复。

解决方法:文件系统 API,Chrome 88-90

ManifestV3 扩展可以使用新的 File System API 来读取文件的内容,例如在通过 web_accessible_resources 公开的 iframe 内。

解决方案 1. 扩展框架,Chrome 91+

使用在带有该 pdf 的选项卡中运行的内容脚本:

    manifest.json 中的
  1. matches 应该包含 <all_urls>file://*/* 并且文件访问应该由用户在 chrome://extensions 扩展程序的 UI。或者你可以使用 activeTab 权限和 programmatic injection 当用户 单击您的扩展程序的图标或通过上下文菜单调用它。
  2. 内容脚本添加了一个不可见的 iframe,指向 web_accessible_resources 中公开的 iframe.html 文件
  3. iframe.html 加载 iframe.js,它照常使用 XMLHttpRequest。由于 iframe 具有 chrome-extension:// URL,因此它的环境 与旧的后台脚本相同,因此您可以执行所有操作 你之前在那里做过。

解决方案 2. 扩展窗口/选项卡,Chrome 91+

另一种解决方案是使用您的任何其他可见页面 扩展程序,如 action 弹出窗口或选项页面或任何其他 chrome-extension:// 属于您的扩展程序的页面,因为它们可以 只需访问 file:// 网址 就像您之前在后台脚本中所做的那样。

注意事项

  • 应该在 chrome://extensions 页面中为此扩展程序启用文件访问。

Express:页面未在 res.redirect() 上更新我必须手动重新加载页面才能看到更改如何解决这个问题?

Express:页面未在 res.redirect() 上更新我必须手动重新加载页面才能看到更改如何解决这个问题?

如何解决Express:页面未在 res.redirect() 上更新我必须手动重新加载页面才能看到更改如何解决这个问题?

基本上,我的用户架构中有一个变量购物车。我正在使用以下代码更新它。

  1. app.get("/cart/:id",function (req,res) {
  2. var productId = req.params.id;
  3. Post.findById(productId,function (err,product) {
  4. if (err) console.log(err);
  5. else {
  6. let index = req.user.cart.indexOf(productId);
  7. if (index >= 0) {
  8. req.user.cart.splice(index,1);
  9. }
  10. req.user.save();
  11. console.log(req.user.cart);
  12. res.redirect("/cart");
  13. }
  14. });
  15. });

更新后,我重定向回 /cart 页面以显示更新的页面。

  1. app.get("/cart",async (req,res) => {
  2. let cart = req.user.cart;
  3. console.log(cart);
  4. let products = [];
  5. for (let i = 0; i < cart.length; i++) {
  6. let product = await Post.findById(cart[i]);
  7. products.push(product);
  8. }
  9. res.render("cart.ejs",{
  10. products: products
  11. });
  12. });

问题是我的 /cart 页面显示了旧的详细信息。只有当我手动重新加载页面时,它才会显示更新的数据。如何修复它以便 /cart 页面始终显示更新的数据。

Google chrome 和 chrome webdriver 安装在 Ubuntu 中,但仍然 driver = webdriver.Chrome('/usr/bin/chromedriver') 失败

Google chrome 和 chrome webdriver 安装在 Ubuntu 中,但仍然 driver = webdriver.Chrome('/usr/bin/chromedriver') 失败

如何解决Google chrome 和 chrome webdriver 安装在 Ubuntu 中,但仍然 driver = webdriver.Chrome(''/usr/bin/chromedriver'') 失败

我是 Ubuntu 的新手。 我成功安装了 google chrome 和 linux chrome 驱动程序。

我导入了以下内容:

  1. from selenium import webdriver
  2. from selenium.webdriver.common.keys import Keys
  3. from selenium.webdriver.common.by import By
  4. from selenium.webdriver.support.ui import webdriverwait
  5. from selenium.webdriver.support import expected_conditions as EC
  6. from selenium.webdriver.common.action_chains import ActionChains

所有这些导入都成功进行。 发布我尝试运行以下代码:

  1. driver = webdriver.Chrome(''/usr/bin/chromedriver'')

它给出了以下错误: selenium.common.exceptions.WebDriverException:消息:未知错误:Chrome 无法启动:异常退出。 (未知错误:DevToolsActivePort 文件不存在) (从 chrome 位置 /usr/bin/google-chrome 启动的进程不再运行,因此 ChromeDriver 假设 Chrome 已崩溃。)

我去 powershell 并检查了 google chrome 和 chromedriver 的安装位置:

enter image description here

我看到它们安装在正确的路径中。但是为什么代码不起作用呢?为什么会报错?

请任何帮助将不胜感激!

解决方法

此问题始于 Google Chrome 90 版。89 版运行良好。我希望谷歌能在 91 版上修复它,但仍然有同样的问题。

install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd

install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd

我们今天的关于在 Robot Framework 中,页面未在 ubuntu:18.04 的无头 chrome 中完全加载的分享就到这里,谢谢您的阅读,如果想了解更多关于Chrome 扩展 - 如何使用 manifest v3 访问本地 file:// 解决方法:文件系统 API,Chrome 88-90解决方案 1. 扩展框架,Chrome 91+解决方案 2. 扩展窗口/选项卡,Chrome 91+注意事项、Express:页面未在 res.redirect() 上更新我必须手动重新加载页面才能看到更改如何解决这个问题?、Google chrome 和 chrome webdriver 安装在 Ubuntu 中,但仍然 driver = webdriver.Chrome('/usr/bin/chromedriver') 失败、install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd的相关信息,可以在本站进行搜索。

本文标签: