File tree 2 files changed +32
-3
lines changed
java/dev/selenium/elements
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 1
1
package dev .selenium .elements ;
2
2
3
- import dev .selenium .BaseTest ;
3
+ import org .junit .jupiter .api .Test ;
4
+ import org .openqa .selenium .By ;
5
+ import org .openqa .selenium .WebDriver ;
6
+ import org .openqa .selenium .WebElement ;
7
+ import org .openqa .selenium .chrome .ChromeDriver ;
8
+ import java .time .Duration ;
4
9
5
- public class FileUploadTest extends BaseTest {
10
+ import java .io .File ;
11
+ import java .nio .file .Path ;
12
+ import java .nio .file .Paths ;
13
+ import java .time .Duration ;
6
14
7
- }
15
+ public class FileUploadTest {
16
+
17
+ @ Test
18
+ public void fileUploadTest () {
19
+ WebDriver driver = new ChromeDriver ();
20
+ driver .manage ().timeouts ().implicitlyWait (Duration .ofMillis (1000 ));
21
+ driver .get ("https://the-internet.herokuapp.com/upload" );
22
+ Path path = Paths .get ("src/test/resources/selenium-snapshot.png" );
23
+ File imagePath = new File (path .toUri ());
24
+
25
+ //we want to import selenium-snapshot file.
26
+ driver .findElement (By .id ("file-upload" )).sendKeys (imagePath .toString ());
27
+ driver .findElement (By .id ("file-submit" )).submit ();
28
+ if (driver .getPageSource ().contains ("File Uploaded!" )) {
29
+ System .out .println ("file uploaded" );
30
+ }
31
+ else {
32
+ System .out .println ("file not uploaded" );
33
+ }
34
+ driver .quit ();
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments