所以我试图在URL中使用这个字符串: -
http://site-test.collercapital.com/Meetings/IC/DownloadDocument?meetingId=c21c905c-8359-4bd6-b864-844709e05754&itemId=a4b724d1-282e-4b36-9d16-d619a807ba67&file=\\s604132shvw140\Test-Documents\c21c905c-8359-4bd6-b864-844709e05754_attachments\7e89c3cb-ce53-4a04-a9ee-1a584e157987\myDoc.pdf
Run Code Online (Sandbox Code Playgroud)
在这段代码中: -
String fileToDownloadLocation = //The above string
URL fileToDownload = new URL(fileToDownloadLocation);
HttpGet httpget = new HttpGet(fileToDownload.toURI());
Run Code Online (Sandbox Code Playgroud)
但在这一点上我得到错误: -
java.net.URISyntaxException: Illegal character in query at index 169:Blahblahblah
Run Code Online (Sandbox Code Playgroud)
我通过一些谷歌搜索意识到这是由于URL中的字符(猜测&),所以我在一些代码中添加,所以它现在看起来像这样: -
String fileToDownloadLocation = //The above string
fileToDownloadLocation = URLEncoder.encode(fileToDownloadLocation, "UTF-8");
URL fileToDownload = new URL(fileToDownloadLocation);
HttpGet httpget = new HttpGet(fileToDownload.toURI());
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行它时,当我尝试创建URL时出现错误,然后错误如下: -
java.net.MalformedURLException: no protocol: http%3A%2F%2Fsite-test.collercapital.com%2FMeetings%2FIC%2FDownloadDocument%3FmeetingId%3Dc21c905c-8359-4bd6-b864-844709e05754%26itemId%3Da4b724d1-282e-4b36-9d16-d619a807ba67%26file%3D%5C%5Cs604132shvw140%5CTest-Documents%5Cc21c905c-8359-4bd6-b864-844709e05754_attachments%5C7e89c3cb-ce53-4a04-a9ee-1a584e157987%myDoc.pdf
Run Code Online (Sandbox Code Playgroud)
在我创建了URL之后看起来我不能进行编码,否则它会替换斜杠和不应该的东西,但是我看不出如何用字符串创建URL然后将其格式化它适合使用.我对这一切并不是特别熟悉,并希望有人能够指出我错过了将字符串A放入适当格式化的URL然后使用正确的字符替换?
任何建议都非常感谢!
我正在自动化网站中的弹出对话框中苦苦挣扎,出于某种原因,它不会单击对话框中的按钮,但与其他所有内容完美交互.它也确定了没有问题的按钮,我可以看到当它看起来运行它似乎点击了按钮颜色改变,所以我有点卡住.
我的代码原本看起来非常明显: -
WebElement targetElement = waitforElement(threadSesh);
targetElement.click();
Run Code Online (Sandbox Code Playgroud)
但当我把它改成以下所有似乎都工作得很好!
WebElement targetElement = waitforElement(threadSesh);
Actions action = new Actions(threadSesh.driver);
action.click(targetElement);
action.perform();
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我为什么一种方法不起作用,而另一种方法工作正常?此外,无论是否有帮助,该网站使用twitter bootstrap构建,如果这有任何区别,但按钮本身是非常基本的,像这样.
<div class="modal hide fade in" style="width: 481px; margin-left: -241px; padding: 15px; display: block;" role="dialog" data-backdrop="static" data-keyboard="false" aria-hidden="false">
...
<div class="modal-footer">
<a id="save-EditDetails" class="btn btn-small btn-info" type="button" style="margin-right: 7px; padding-left: 15px; padding-right: 15px;" data-bind="click: ok" href="#">Save</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 这是我的第一篇帖子,所以要温柔!:)
我已经设置了一个grails项目(相当粗糙的grails项目)并尝试将其连接到SQL 2008数据库,我已将jtds-1.3.0.jar添加到lib文件夹和我的构建路径中,然后我将我的DataSource.groovy文件修改为如下: -
dataSource {
pooled = true
driverClassName = "net.sourceforge.jtds.jdbc.Driver"
dialect = "org.hibernate.dialect.SQLServerDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
development {
dataSource {
dbCreate = "update"
url= "jdbc:jtds:sqlserver://TestServer:1433;databaseName=TestTable"
username = "test"
password = "test"
// logSql=true
}
}
Run Code Online (Sandbox Code Playgroud)
麻烦的是,当我尝试编译时,我得到一个大的错误,如下所示,我错过了什么?我用google搜索但找不到明显的解决方案......:S
| Error 2013-03-08 12:44:33,451 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean …Run Code Online (Sandbox Code Playgroud) 我有一个列表视图,对于每一行,我想要一个链接到另一个列表视图,显示相关结果.我最终设法构建的createlink行看起来像这样
<a href="${createLink(controller : 'RunResults', action:'ListSpecific', params:'[id:testExecQueueInstance.id]')}">my link</a>
Run Code Online (Sandbox Code Playgroud)
这会生成链接
http://localhost:3278/FARTFramework/runResults/listSpecific/testExecQueueInstance.id
Run Code Online (Sandbox Code Playgroud)
我知道testExecQueueInstance.id是22,我希望链接实际上看起来像这样
http://localhost:3278/FARTFramework/runResults/listSpecific/22
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我的想法是,我有一个像这样的控制器,然后应该列出那些匹配该ID的项目...
def ListSpecific(int id){
render(view: "list", model: [runResultsInstanceList: RunResults.findAllByTestExeQueueID(id, [sort:"testExecTime", order: "desc"]), runResultsInstanceTotal: RunResults.count()])
}
Run Code Online (Sandbox Code Playgroud) 有谁知道我如何利用Java使用“以其他用户身份运行”功能来获取硒以运行IE会话?我不知道该如何设置,Google不会显示任何内容,所以也许我在某处搜索错误的东西?
为了进一步说明为什么我需要这样做,我正在测试的网站是一个内部平台,它使用用户登录凭据/ Windows帐户详细信息来确定其角色,拥有的链接,可以查看的数据等。
当前,我可以以特定用户(经理,数据管理员等)运行测试的唯一方法是在运行测试之前以该用户身份登录计算机。当我有多个用户帐户要测试并且正在运行带有GRID2的Webdriver时,这实际上是不可能的(因此,我有一堆机器在队列出现时从队列中提取测试)。
当手动运行测试时,我可以简单地右键单击并在快捷方式上选择“以其他用户身份运行”选项,这样可以确定是否可以通过webdriver运行它时找到一种复制该方法的方法。
感谢您的任何建议或帮助。
我想知道是否有其他人遇到过这个问题.我有一个使用twitter bootstrap的网站,在我的脚本中的一个点我打开一个模态,我经历并与该模态中的几个对象(文本输入,下拉列表,复选框)进行良好的交互.但是当我最后点击提交按钮时,没有任何反应.
就硒而言,它点击它,如果我在运行时观看屏幕,可以看到按钮突出显示就像点击一样,但没有任何反应.如果我之后尝试点击它,除按钮突出显示之外仍然没有任何反应.如果我然后按RETURN或ENTER然后它会发射...
我试过而不是单击发送ENTER或RETURN但它们都做同样的事情而且完全失去了,我通过XPATH识别对象,据我所知看起来正确...
这是代码中的一大块,请记住在此之前的所有内容......
threadSesh.driver.findElement(By.xpath(".//*[@id='createDeal']").click();
threadSesh.driver.findElement(By.xpath("html/body/div[3]/div[2]/div/dl/dd[1]/input").clear();
threadSesh.driver.findElement(By.xpath("html/body/div[3]/div[2]/div/dl/dd[1]/input").sendKeys("MyNewProject");
Select myDropDown = new Select(threadSesh.driver.findElement(By.xpath("html/body/div[3]/div[2]/div/dl/dd[3]/select")));
myDropDown.selectByVisibleText("Buy Out");
threadSesh.driver.findElement(By.xpath(".//*[@id='ProjectOriginator']/li/input").click();
threadSesh.driver.findElement(By.xpath(".//*[@id='ProjectOriginator']/li/input").sendKeys("John smith");
threadSesh.driver.findElement(By.xpath("(//a[contains(text(),'Create')])[2]").click();
Run Code Online (Sandbox Code Playgroud)
它的最后一行什么都不做......任何建议都将非常感谢!
另外值得指出我正在使用ie并且无法在chrome或FF中测试这个(这个网站上我不测试版本,它是一个内部平台).
另一个可能有用的信息,按钮实际上不是一个按钮,而是使用twitter bootstrap东西看起来像按钮的某种类型的参考,它的来源如下: -
<a class="btn btn-small btn-info" type="button" style="margin-right: 7px; padding-left: 15px; padding-right: 15px;" data-bind="click: ok" href="#">Create</a>
Run Code Online (Sandbox Code Playgroud)
如果我将它记录在firefox的seleneium addin中,则输出:
driver.findElement(By.xpath("(//a[contains(text(),'Create')])[2]")).click();
Run Code Online (Sandbox Code Playgroud) 我在我的脚本中有一个方法,我在循环中使用它来确定对象是否在尝试与之交互之前是否已启用并显示,如下所示: -
public boolean isElementPresent(By myObject, individualThreadSession threadSesh) {
try{
if(threadSesh.driver.findElement(myObject).isEnabled() && threadSesh.driver.findElement(myObject).isDisplayed()) {
return true;
} else {
return false;
}
}
catch (NoSuchElementException e){
return(false);
}
}
Run Code Online (Sandbox Code Playgroud)
该myobject部分从读取的内容传入: -
isElementPresent(By.xpath(IDString),threadSesh)
所以我传递相关的By(通过运行时指定的数据确定)
到目前为止,这对我来说已经很好了很长一段时间.我点击一个链接后,我试图点击插入页面的对象,问题是Selenium threadSesh.driver.findElement(myObject).isDisplayed()在屏幕上清晰可见对象的部分返回false .
我可以手动与这个对象进行精细交互,如果我使用IDE记录它,它似乎工作得很好......任何人都知道如何解决这个问题?或者强迫Selenium认为对象是显示的?
当我没有添加对象时,我正在处理的区域的HTML如下: -
<td class="activecomment">
<div data-bind="template: { name: 'commentControlPriorities', data: $data }" style="position: relative">
<div style="margin-right: 10px" data-bind="with: $data.LatestComment, flash: $data.LatestComment">
<div data-bind="style: { display: editMode() ? 'none' : 'block' }" style="display: block;">
<!-- Highlighted comment -->
<div …Run Code Online (Sandbox Code Playgroud) 希望是一个简单的!
我一直试图让这个工作几个小时,但我没有运气,因为我对regexp很新,我可能会错过一些非常明显的东西,并希望有人能指出我正确的方向.我想要匹配的模式如下: -
至少一个或多个数字+"##"+至少一个或多个数字+"##"+至少一个或多个数字
所以有效组合的几个例子是: - 1 ## 2 ## 3 123#123#123 0 ## 0 ## 0
一些无效的组合将是## b ## c 1 ## ## 1
我有这样的正则表达式: -
[\d+]/#/#[\d+]/#/#[\d+]
Run Code Online (Sandbox Code Playgroud)
我正在使用它(请注意字符串中的双斜线): -
var patt = new RegExp("[\\d+]/#/#[\\d+]/#/#[\\d+]");
if(newFieldValue!=patt){newFieldValue=="no match"}
Run Code Online (Sandbox Code Playgroud)
我也试过这些但仍然没有: -
if(!patt.text(newFieldValue)){newFieldValue==""}
if(patt.text(newFieldValue)){}else{newFieldValue==""}
Run Code Online (Sandbox Code Playgroud)
但我没有尝试匹配,我在哪里错了?
任何指针都感激不尽,欢呼!