【发布时间】:2014-12-11 03:21:30
【问题描述】:
我一直在与 Selenium 和 Fiverr.com 合作,遇到了一些问题,希望能得到一些帮助。我正在尝试创建一个新的演出,并且我已经设法完成了所有事情,但有些事情仍然困扰着我。一件事是图片上传。
• 您有一个按钮,您单击文件输入类型 () 会弹出一个 Windows 对话框,到目前为止,我使用 SendKeys.SendWait 的计划已经奏效,除了在 Windows 对话框上按“打开”的部分提交图片。我试过使用 SendKeys.SendWait("{ENTER}") 来点击它,但到目前为止这对我没有用,所以有什么想法吗?除非 P/Invoke 可以处理 Windows 对话框,否则我想不出任何其他方法?
•我也在尝试在“描述”框中输入文本,但还不能这样做。我试图通过类名来获取它,但它告诉我它无法访问该类,因为它是隐藏的,还尝试通过 Javascript (IJavaScriptExecutor) 像这样:
IWebElement detailFrame = firefoxDriver.FindElement(By.XPath("/html/body"));
var executor = firefoxDriver as IJavaScriptExecutor;
executor.ExecuteScript("arguments[0].innerHTML = 'hiiiiiiii'", detailFrame);
这很奇怪,因为他们将正文用于文本字段,如下所示:
<body marginwidth="0" marginheight="0" spellcheck="true" class="wysihtml5-editor" contenteditable="true" style="color: rgb(119, 119, 119); cursor: auto; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal; letter-spacing: normal; text-align: start; text-decoration: none; text-indent: 0px; text-rendering: auto; word-break: normal; word-wrap: break-word; word-spacing: 0px; overflow: auto; background-color: rgb(255, 255, 255);">TEXT HERE<span id="_wysihtml5-undo" class="_wysihtml5-temp"></span></body>
我认为他们使用了两个不同的“body”,但 XPath 只是显示它是 /html/body。我该如何设置这样的文本?
谢谢你们的帮助,过去两个小时一直在做这个。
【问题讨论】: