Mapa mental
Selenium
Conteúdo do mapa
Selenium
It is a open-source testing framework for Web applciations
- contain Tools & APIS
Kind of
- Selenium IDE
- It is a Firefox plugin
- Goal: Record and play actions
- It is a Firefox plugin
- Selenium RC
- A client/server system for execute tests in different languages. It is deprecated.
- Selenium WebDriver
- This actually provide the tools, libraries, drivers for support in programming languages in order to automate actions
- Driver
- functions to control browser
- Driver
- This actually provide the tools, libraries, drivers for support in programming languages in order to automate actions
- Selenium GRID
- It let run automation remotely in all browsers.
- Selenium IDE
Locators
- Attributes-based
- By.id
- Find an element by id, it is the first choice, id is unique: <div id="toolbar">.....</div>
- WebElement Ele = driver.findElement(By.id("toolbar"));
- Find an element by id, it is the first choice, id is unique: <div id="toolbar">.....</div>
- By.name
- Find an element by name attribute, as long as it is unique: <input name="register" class="required" type="text"/>
- WebElement register= driver.findElement(By.name("register"));
- Find an element by name attribute, as long as it is unique: <input name="register" class="required" type="text"/>
- By.linkText
- Find a element by link text: <a href="http://www.seleniumhq.org">Downloads</a>
- WebElement download = driver.findElement(By.linkText("Downloads"));
- Find a element by link text: <a href="http://www.seleniumhq.org">Downloads</a>
- By Partial LinkText
- Same to Link Text, including <anchor> tag
- By TagName
- TagName can be used with Group elements like , Select and check-boxes / dropdowns
- By.className
- Find elements by class attribute
- By.id
- Structure-based
- XPath
- It is a standard navigation tool for XML, HTML document is also an XML document (xHTML)
- Native Xpath
- html/head/body/table/tr/td
- Relative Xpath
- Find an image: xpath=//img[@alt='image alt text']
- Get an cell element: xpath=//table[@id='table1']//tr[4]/td[2] xpath=(//table[@class='nice'])//th[text()='headertext']/
- Link element: xpath=//a[contains(@href,'href goes here')]
- Input element: xpath=//input[@name='name2' and @value='yes']
- or xpath =//*[@name='name2']
- Native Xpath
- How can I create an xpath locator?
- 1. Firebug tool ==> Native XPath, absolute path
- 2. FirePath tool ==> Relative XPath
- 3. Mix both: New relative xpath: //body//footer/section[3]/div/ul/li[3]/a Another relative xpath: //body//section[3]/div/ul/li[3]/a
- 4. Containing a Keyword: link picture with profile keyword: //img[contains(@src,’Profile’)]
- 5. Start with a keyword: picture alt with the keyword: //img[starts-with(@alt,’Visit Us On Linkedin’)]
- 6. find a text: //*[text() = 'something'], //a[contains(text(), 'part link name')]
- It is a standard navigation tool for XML, HTML document is also an XML document (xHTML)
- CssSelector
- XPath
- Attributes-based
Wait commands
- Explicit waits
- more user-controlled approach. Set a timeout specific for another elements.
- WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.elementToBeClickable(downloadLink));
- presenceOfElementLocated – Waits for an element to be present in the DOM; returns the WebElement visibilityOfElementLocated – Waits for an element to be visible; returns true if the element is visible invisibilityOfElementLocated – Waits for an element to be invisible; returns true if the element is not visible elementToBeClickable – Waits for element to be clickable, i.e., visible and enabled; returns the WebElement alertIsPresent – Waits for an alert to be present; returns the alert if present titleIs – Waits for the title to match a specific value elementSelectionStateToBe – Waits for an element to be selected or not frameToBeAvailableAndSwitchToIt – Waits for a frame to be available and switches to it so we can interact with the contents of the frame titleContains – Waits for the title to contain a String; returns true when title matches urlContains – Waits for the URL to contain a specific String urlMatches – Waits for the URL to match a specific regular expression urlToBe – Waits for the URL to be an exact String
- WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.elementToBeClickable(downloadLink));
- more user-controlled approach. Set a timeout specific for another elements.
- Implicit waits
- WebDriver will: try to find it, fail,
- instead of throwing a NoSuchElementException exception, WebDriver will wait for 500 milliseconds, then WebDriver will try to find it again
- It is configured by using the manage timeouts functionality from the WebDriver API.
- driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
- WebDriver will: try to find it, fail,
- Explicit waits
Informações
- Descrição
- Mapa Mental sobre Selenium, criado por Alejandra Neolopan em 05-04-2016.
- Criado por
- Alejandra Neolopan
- Visualizações
- 1
- Avaliação