Thursday, August 29, 2024

Selenium

Components of Selenium

  1. Selenium IDE
  2. Selenium RC
  3. Selenium Webdriver - communicated with Browser
  4. Selenium Grid
Limitations
  1. Image not supported
  2. no reports
  3. No RestAPI or Database support
  4. No Mobile testing
  5. Can not handle popup
  6. Dynamic content????
WebDriver Capabilities (not not in RC):
  1. multiple frames
  2. pop-ups
  3. browser windows
  4. alerts
  5. page navigation
  6. drag & drop
  7. Ajax
Object Repository
Wait:
  1. Implicit - wait for
  2. Explicit
    1. WebDriver wait
    2. Fluent wait
Locators types
  1. id
  2. name
  3. link Text
  4. Partial Link Text
  5. CSS Selector
  6. xpath
FindElement/elements
  1. driver.findElement(By.id("")
Size of the Window
  1. maximize()
  2. getSize()
  3. setSize()
  4. JavaScriptExecutor: executeScript - executeAsyncScript - for scroll
POM - Page Object Model
Page Factory

Action Class - mouse/keyboard
drag and drop, control key

Alerts
  1. void dismiss()
  2. void accept()
  3. String getText()
  4. void sendKeys(String stringToSend)
Robot (Native) - mouse & keyboard
  1. upload files
  2. keyPress()
  3. keyRelease()
  4. MouseMove()
  5. MousePress()
  6. mouseRelease()
Screenshot
  1. File src = ((TakeScreenshot)driver)getScreenshotAs(OutputType FILE);
Window Handle
  1. get.windowhandle()
  2. get.windowhandles()
  3. set
  4. switch to
  5. action
Listeners

  1. Event Listeners
Assert and verify
Proxy
String PROXY="192.168/0.0:4444";
Capability.setCapability(CapabilityType.PROXY,proxy)
Network Latency = driver.manage.pageLoadingTime()
Serversidelog: java -jar.jar -log selenium.log

Exceptions:
  1. WebDriverException
  2. NoAlertPresentException
  3. NoSuchElementException
  4. NoSuchFrameException
  5. NoSuchWindowException
  6. Timeout

driver.switchTo.frame() - name, number