Содержание
- 2. Element selection WebElement cheese = driver.findElement(By.id("cheese"));
- 3. Locating by ID WebElement elem = driver.findElement(By.id("email"));
- 4. Locating by ClassName WebElement elem = driver.findElement(By.className("inputtext"));
- 5. Locating by Name WebElement elem = driver.findElement(By.name("userName"));
- 6. Locating by TagName WebElement elem = driver.findElement(By.tagName("strong"));
- 7. Locating by Link text WebElement elem = driver.findElement(By.linkText("REGISTER"));
- 8. Locating by Partial link text WebElement elem = driver.findElement(By.partialLinkText("STER"));
- 9. Locating by xpath WebElement elem = driver.findElement(By.xpath("//img[@src=’/images/hdr_right.gif’]"));
- 10. Locating by cssSelector WebElement elem = driver.findElement(By.cssSelector("input.inputtext[tabindex=1]"));
- 11. Xpath
- 12. Xpath Xpath - It is a syntax or language for finding any element on the web
- 13. Syntax
- 14. Types of X-path 1) Absolute XPath html/body/div[1]/section/div[1]/div/div/div/div[1]/div/div/div/div/div[3]/div[1]/div/h4[1]/b 2) Relative XPath. For Relative Xpath the path starts
- 15. 1) Basic XPath: Xpath=//input[@name='uid'] Xpath=//input[@type='text'] Xpath= //label[@id='message23'] Xpath= //input[@value='RESET'] Xpath=//*[@class='barone'] Xpath=//a[@href='http://demo.guru99.com/'] Xpath= //img[@src='//cdn.guru99.com/images/home/java.png']
- 16. 2) Contains(): Xpath=//*[contains(@type,'sub')] Xpath=//*[contains(@name,'btn')] Xpath=//*[contains(@id,'message')] Xpath=//*[contains(text(),'here')] Xpath=//*[contains(@href,'guru99.com')]
- 17. 3) Using OR & AND: Xpath=//*[@type='submit' or @name='btnReset'] Xpath=//input[@type='submit' and @name='btnLogin']
- 18. 4) Starts-with function: Id=" message12" Id=" message345" Id=" message0873" Id=" message8769" Xpath=//label[starts-with(@id,'message')]
- 19. 5) Text(): Xpath=//td[text()='UserID']
- 20. 6) XPath axes methods: a) Following - Selects all elements in the document of the current
- 21. Predicates
- 22. CSS
- 23. Css selectors When we don't have an option to choose Id or Name, we should prefer
- 24. Css selector and classes Log in WebElement ele1 = driver.findElement(By.cssSelector(".primary-btn")); WebElement ele2 = driver.findElement(By.cssSelector(".btn.primary-btn")); WebElement ele3
- 25. Special characters 1. '^' symbol, represents the starting text in a string. 2. '$' symbol represents
- 29. xpath or css
- 30. { table_header_id_and_class: { css: "table#large-table thead .column-50", xpath: "//table[@id='large-table']//thead//*[@class='column-50']" }, table_header_id_class_and_direct_desc: { css: "table#large-table > thead
- 31. Xpath vs Css XPath we can traverse both forward and backward Any set of conditions for
- 33. Скачать презентацию