【问题标题】:FoxPro and Internet Explorer 10FoxPro 和 Internet Explorer 10
【发布时间】:2015-06-05 19:33:37
【问题描述】:

我在使用 Internet Explorer API 时遇到问题。 之前我曾经使用

连接、授权和按下网站上的按钮
ie = CREATEOBJECT("InternetExplorer.Application")
ie.navigate('site')
ie.document.all("login").value = login
ie.document.all("password").value = password
ie.document.all("auth").click

现在这个站点不支持 Internet Explorer,或者更确切地说,不支持 IE 的兼容性设置。

当兼容性设置打开时,我可以使用这种方式进行授权,但之后无法单击脚本(甚至手动),当兼容性设置关闭时,我无法授权并手动单击。

请告诉我,另一种打开资源管理器、阅读内容、填写字段以及单击按钮和脚本链接的方法?

【问题讨论】:

    标签: internet-explorer automation click


    【解决方案1】:

    我会这样做:

    IE = CreateObject("InternetExplorer.Application")
    IE.navigate("site")
    IE.Visible = .t.
    
    Do While IE.readystate <> 4
    enddo
    
    IE.document.getElementbyId("login").focus(1) && Mark the parameter, can be anything, no matter what.
    IE.document.getElementbyId("login").value = "login"
    IE.document.getElementbyId("password").value = "password"
    IE.document.getElementbyId("auth").click(1)  && Mark the parameter, can be anything, no matter what.
    

    替代方案: ie.document.forms(0).submit(1) && 0 in forms() 是站点依赖 ie.document.forms(0).elements(4).click(1) && 第四个元素是站点相关

    没有关于参数 (1) 的文档,而且似乎只有 VFP 需要从 IE9 开始。任何值或类型都可以。

    【讨论】:

    • 我刚试过这个。关闭兼容性设置时,Internet Explorer 不支持“getElementbyId”。
    • 你知道吗,我可以使用 CREATEOBJECT("Wscript.Shell") 打开浏览器,然后单击网页上的某个按钮,或者使用 CREATEOBJECT('HYPERLINK') 做同样的事情吗?
    • 我的答案不是关于 GetElementbyID,而是关于 click(1) 中的 (1) 参数。这解决了你的问题。如果 GetElementbyID 不起作用,那是因为特定站点不允许这种访问方式。如果 ie.document.all("login").value 对您有用,那很好。或者你可以使用 forms(#x).Elements(#y)
    猜你喜欢
    • 2013-04-10
    • 1970-01-01
    • 2013-01-19
    • 2013-12-01
    • 2015-11-01
    • 2017-09-24
    • 2013-07-09
    • 2013-11-11
    • 1970-01-01
    相关资源
    最近更新 更多