GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — DevOps_ClassNotes/Selenium Notes.txt at master · madala0611/DevOps_ClassNotes Expand file tree/ Copy pathSelenium Notes.txtMore file actions 127 lines (66 loc) · 2.52 KB / Copy pathSelenium Notes.txtFile metadata and controls127 lines (66 loc) · 2.52 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 selenium webdriver create maven project --> src/main folder --> create a package --> create a new class --myfirstTestcase public class MyfirstTC{ public static void main(String[] args) throws InterruptedException { // TODO Auto-generated method stub WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Selenium+%28software%29"); Thread.sleep(2000); driver.findElement(By.id("wpName2")).sendKeys("sonal" // Now use XPATH to write the locator value. // Add wait time } } --> create another new class for testNG --> wikitestcase public class WikiTestCase { public static WebDriver driver; @BeforeClass public static void setup() { System.setProperty("webdriver.chrome.driver", "C:\\Users\\vishal mittal\\Downloads\\chromedriver_win32 (12)\\chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); // maximize the browser window driver.manage().deleteAllCookies(); // delete cookies on the browser driver.get("https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Selenium +%28software%29"); driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // implicit wait driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS); } @Test(priority='1') public void createAccount() throws InterruptedException { // test steps to perform testcase goes here driver.findElement(By.id("wpName2")).sendKeys("Username1"); Thread.sleep(3000); // Inspect password textbox and enter data in the text box driver.findElement(By.name("wpPassword")).sendKeys("password@123"); WebElement e= driver.findElement(By.xpath("//button[@value='Create your account']")); // if we add Thread.sleep(10000);// waiting until 10 seconds e.click(); } @AfterClass public void closebrowser() { driver.close(); } *********************************************** TestNG.xml Create folder src/main/resources Create a file with extension .xml <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" > <suite name="8PMproject" verbose="1" > <test name="Selenium scripts" > <classes> <class name="packagename.classname" /> </classes> </test> </suite> Now run the projects as Run As--> MAVEN Test **************************************************** Upload in git Show in jenkins. |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |