我一直在做一些与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>
我认为他们使用的是两种不同的“人体的”,虽然,但XPath的只是表明它的/ HTML/BODY。我将如何设置这样的文本?
谢谢你们的帮助,在过去的两个小时里一直在这里。
告诉我无法找到元素(_wysihtml5-undo),我试过了XPath以及ID,有什么想法吗? – Frank 2014-12-11 17:33:01
你能告诉我你正在尝试的步骤吗? – Saifur 2014-12-11 17:51:52
firefoxDriver.FindElementById(“_ wysihtml5-undo”)。SendKeys(“Hi”); 或 firefoxDriver.FindElementByXPath(“// * [@ id ='_ wysihtml5-undo']”)。SendKeys(“Hi”); 两者都抛出相同的错误,它找不到。 – Frank 2014-12-11 23:47:38