将 AutoIT 与 Selenium 结合使用 [英] Using AutoIT with Selenium

查看:39
本文介绍了将 AutoIT 与 Selenium 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您回答我之前的问题,但随着一个问题的解决,显然又找到了另一个问题.

Thank you for answering my previous question but as one is solved another is found apparently.

与 Flash 游戏本身交互是现在的问题.我曾尝试研究如何在 Selenium 中做到这一点,但无法做到.我见过 FlashSelenium、Sikuli 和 AutoIT.

Interacting with the flash game itself is now the problem. I have tried researching how to do it in Selenium but it can't be done. I've seen FlashSelenium, Sikuli, and AutoIT.

我只能在 Java 中找到 FlashSelenium 的文档,使用 AutoIT 而不是 Sikuli 对我来说更容易,因为我必须学习使用 Jpython 来创建我想要的那种脚本,我并没有偏离学习只是试图尽快完成.至于 AutoIT,唯一的问题是我不明白如何将它与 seleium 一起使用

I can only find documentation for FlashSelenium in Java, It's easier for me to use AutoIT rather than Sikuli as I'd have to learn to use Jpython to create the kind of script I want to, which I am not straying away from learning just trying to finish this as fast as possible. As for AutoIT, the only problem with it is that I don't undertsand how to use it with seleium

from selenium import webdriver
import autoit
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://na58.evony.com/s.html?loginid=747970653D74727947616D65&adv=index")
driver.maximize_window()
assert "Evony - Free forever " in driver.title

到目前为止我已经有了这个,它正在做应该做的事情,即使用driver.get"创建一个新帐户,但是当我到达该页面时,它全是闪存,我无法与其中的任何内容进行交互网页,所以我必须使用 AutoIT,但我不知道如何让它从硒停止的地方提取".我希望它与网页上的按钮进行交互,并且通过查看以前在 stackoverflow 上的帖子,我可以使用 (x,y) 来指定位置,但不幸的是,该帖子并没有对此进行解释.任何和所有信息都会很棒,谢谢.

So far I have this and It's doing what is suppose to do which is create a new account using that "driver.get" but when I reach to the page, it is all flash and I can not interact with anything in the webpage so I have to use AutoIT but I don't know how to get it to "pick-up" from where selenium left off. I want it to interact with a button on the webpage and from viewing a previous post on stackoverflow I can use a (x,y) to specify the location but unfortunately that post didn't explain beyond that. Any and all information would be great, thanks.

推荐答案

是的,您可以使用任意数量的抓取库 (scrapy美汤 都易于使用且功能强大).不过就我个人而言,我喜欢 Selenium 及其 python 绑定,因为它们是最灵活的.您的最终脚本如下所示:

Yes, you can use any number of scraping libraries (scrapy and beautiful soup are both easy to use and very powerful). Personally though, I like Selenium and its python bindings because they're the most flexible. Your final script would look something like this:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://xx.yy.zz")

# Click the "New comer, click here to play!" button
elem = driver. find_element_by_partial_link_text("Click here to play")
elem.send_keys(Keys.RETURN)

你能发布页面的来源是什么样的吗(也许使用 Pastebin)?

Can you post what the source of the page looks like (maybe using a Pastebin)?

更新,向您展示如何点击点击此处播放"按钮.

updated to show you how to click the "Click here to play" button.

这篇关于将 AutoIT 与 Selenium 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆