forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webdriven: Fixing attachFile command and adding a test for this comma…
…nd (it is not included in the suite because it should be run in local env only and can't be run on CI server at the moment)
- Loading branch information
Showing
2 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
java/client/test/com/thoughtworks/selenium/corebased/TestAttachFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
|
||
package com.thoughtworks.selenium.corebased; | ||
|
||
import com.google.common.base.Charsets; | ||
import com.google.common.io.Files; | ||
|
||
import com.thoughtworks.selenium.InternalSelenseTestBase; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class TestAttachFile extends InternalSelenseTestBase { | ||
|
||
private static final String LOREM_IPSUM_TEXT = "lorem ipsum dolor sit amet"; | ||
private static final String FILE_HTML = "<div>" + LOREM_IPSUM_TEXT + "</div>"; | ||
|
||
private File testFile; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
testFile = createTmpFile(FILE_HTML); | ||
} | ||
|
||
private File createTmpFile(String content) throws IOException { | ||
File f = File.createTempFile("webdriver", "tmp"); | ||
f.deleteOnExit(); | ||
Files.write(content, f, Charsets.UTF_8); | ||
return f; | ||
} | ||
|
||
@Test | ||
public void testAttachFile() throws Exception { | ||
selenium.open("/common/upload.html"); | ||
selenium.attachFile("upload", testFile.toURI().toURL().toString()); | ||
selenium.click("go"); | ||
selenium.waitForPageToLoad("30000"); | ||
selenium.selectFrame("upload_target"); | ||
assertEquals(selenium.getText("//body"), LOREM_IPSUM_TEXT); | ||
} | ||
} |