Selenium-当输入中不存在HTML代码和Web使用SelectFileDialog中时,将图像上传到网站

发布于 2025-02-12 20:40:40 字数 21879 浏览 1 评论 0 原文

我有这个问题,因为我找不到适当的解决方案。

在网站上,我正在尝试使用代码更改个人资料图片。有“上传”按钮,可以打开selectfiledialog。

当我尝试通过document.getElementsbytagname(“输入”)找到输入标签时,它找不到上传的任何输入。 (所以我不能只做element.sendkeys()),

当我选择对话框中的文件时,它可以使用这种方式,然后网站将其转换为数据URI并将其设置为< img> src +它设置样式=变换:矩阵(values params)

所以我找到了这个解决方案,它将图像转换为数据URI并将其设置为 src 参数像网站一样。我还计算矩阵参数值。

我的问题是,当我稍后单击“保存”按钮时,由于某种原因,网站重置我的CSS样式,然后在我更改 src 的情况下将图片保存不良

(以前的Avatar中保留了Transform样式保留)

“”

这就是我通过上传按钮上传手动时的外观,否则我可以matrix()值 “”

但是当我单击“保存”按钮时,它会像第一张图片一样保存,就像它不会在我的矩阵中计数( )值。我可以以某种方式进入保存按钮函数并在我的matrix()编辑中强制强制吗?还是在不按按钮的情况下模拟上传功能? 时,如何处理硒中的selectfiledialog

  1. 或者,当没有&lt ;输入>在html代码中,
  2. 我不能使用system.windows.forms.sendkeys.sendwait(path);

我还尝试使用autoitx,但是我的项目中的库遇到了一些问题,如果可能的话,我想在没有库的情况下处理它。 非常感谢您的所有答案:)

**编辑 我找到了其中包含代码的.js文件,但是我不知道如何调用例如在方法图像 javaScript的代码

I have this problem for I can't find proper solution.

On website trovo.live I'm trying to change profile picture with code. There is 'Upload' button, which opens SelectFileDialog.

When I try to find input tag via document.getElementsByTagName("input") it doesn't find any input for uploading. (So I can't just do element.SendKeys() )

It works this way, when I select file in dialog then website converts it into data URI and set it as < img > src + it sets style = transform: matrix(values params)

So I found this solution that I convert image into data URI and set it as src parameter like website do it. Also I calculate matrix parameter values.

My problem is when I click save button later, website for some reason resets my css style and then picture is saved with bad positioning

After I change src by code (transform style remains from previous avatar)

This is how it looks when I upload manualy by Upload button or I can matrix() values

But when I click save button, it saves like that first picture, like it wouldn't count in my matrix() values. Can I somehow get into save button function and force in my matrix() edit? Or simulate Upload function without pressing button?
Or how can I handle selectFileDialog in selenium when

  1. No < input > in HTML code
  2. I can't use System.Windows.Forms.SendKeys.SendWait(path);

I also tried to use AutoItX, but I had some problems with their library in my project and I would like to handle it without libraries if possible.
Thank you very much for all answers :)

**edit
I found .js file which contains code for it, but I have no idea how to call for example method for resizing on method image code for javascript

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文