我想在 Facebook 广告管理器中自动执行一项简单的任务.此任务涉及设置活动和上传一些广告.人类可能需要 30 分钟才能做到这一点.然而,他们每次都在做同样的事情.经常有错误.这应该是自动化的.没有人的情感或错误就完成了.
I want to automate a simple task inside Facebook Ads Manager. This task involves setting up a campaign and uploading some ads. It can take a human 30 minutes to do this. However, they're doing the same thing every single time. Often with mistakes. It's something that should be automated. Done without human emotion or mistakes.
Facebook 非常敏感,我不希望它因为错误的原因禁止我.所以我需要感受人性.我可以在点击之间花时间.但是,光标移动本身需要感觉人性化.出于道德目的,我只需要模拟真实的人类点击.
Facebook is very sensitive and I don't want it to ban me for the wrong reasons. So I need to feel human. I can take my time between clicks. However, the cursor movement itself needs to feel human. I only need to simulate a real human click for ethical purposes.
假设我得到了一个想要将光标移向的元素:
Say I get an element I want to move my cursor towards:
WebDriver driver;
// Set file path of chrome driver
System.setProperty("webdriver.chrome.driver", "C:\chromedriver.exe");
// Create object
ChromeDriver driver = new ChromeDriver(options);
// Go to URL
driver.get("FACEBOOK URL");
// Get element
driver.findElement(By.xpath("//span[contains(text(), 'Setup Campaign')]");
像真人一样将光标移向该元素的最佳方法是什么?
What is the best way to move my cursor towards this element as a real human would?
真正的人类会首先移动鼠标.不只是点击元素
A real human would first move the mouse. Not just click the element
他们会缓慢移动鼠标/光标.最多可能需要 500-1000 毫秒.当然不是立即.
They would move the mouse/cursor slowly. It could take up to say 500-1000 milliseconds. Certainly not instantly.
他们会以弯曲的方式移动鼠标/光标.不仅仅是100%的直线.可能,以随机方式?那么可能需要一些随机性元素?
They would move the mouse/cursor in a curved fashion. Not just in a 100% straight line. Possibly, in a random fashion? So some elements of randomness may be needed?
我对 Selenium 还是很陌生,因此我们将不胜感激.
I'm quite new to Selenium, so any input would be greatly appreciated.
我正在用 Java 编写代码 :)
I am writing my code in Java :)
WebDriver 不使用操作系统输入;它通过http协议直接与浏览器通信.如果您想模拟像真实"鼠标输入一样的通信,您必须使用使用基于操作系统的框架的自动化解决方案.如果是 Windows,您可以使用例如:
WebDriver doesn't use an operating system input; it communicates directly with the browser via http protocol. If you want to simulate communication like a 'real' mouse input you have to use an automation solution that uses operating system based frameworks. In case of Windows you can use e.g.:
这篇关于Selenium WebDriver/Java - 模拟人类光标移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!