-
Open a browser
# start an instance of firefox with selenium-webdriver driver = Selenium::WebDriver.for :firefox # :chrome -> chrome # :ie -> iexplore
- Go to a specified URL
| # Ways to execute a shell script in Ruby | |
| # Example Script - Joseph Pecoraro | |
| cmd = "echo 'hi'" # Sample string that can be used | |
| # 1. Kernel#` - commonly called backticks - `cmd` | |
| # This is like many other languages, including bash, PHP, and Perl | |
| # Synchronous (blocking) | |
| # Returns the output of the shell command | |
| # Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
| # These are my notes from the PragProg book on CoffeeScript of things that either | |
| # aren't in the main CS language reference or I didn't pick them up there. I wrote | |
| # them down before I forgot, and put it here for others but mainly as a reference for | |
| # myself. | |
| # assign arguments in constructor to properties of the same name: | |
| class Thingie | |
| constructor: (@name, @url) -> | |
| # is the same as: |
| package com.test; | |
| import java.net.MalformedURLException; | |
| import java.net.URL; | |
| import org.openqa.selenium.By; | |
| import org.openqa.selenium.remote.DesiredCapabilities; | |
| import org.openqa.selenium.support.events.EventFiringWebDriver; | |
| import org.testng.annotations.Test; |
| package testng.samples; | |
| import org.testng.IExecutionListener; | |
| import org.testng.ITestNGListener; | |
| import org.testng.ITestNGListenerFactory; | |
| import org.testng.annotations.Listeners; | |
| import org.testng.annotations.Test; | |
| /* |
| Suites: 0 and:0 | |
| [TestNG] Running: | |
| C:\Users\krmahadevan\AppData\Local\Temp\testng-eclipse--361118992\testng-customsuite.xml | |
| [TestRunner] Starting executor for test Default test with time out:2147483647 milliseconds. | |
| bar() running in Thread #11 | |
| foo() running in Thread #12 | |
| Started InternetExplorerDriver server (32-bit) | |
| 2.26.0.6 | |
| Listening on port 36943 |
| package testng.samples; | |
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.Random; | |
| import org.testng.ITestContext; | |
| import org.testng.TestNG; |
| driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); | |
| @Test | |
| public void test() throws Exception { | |
| try{ | |
| driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[id='**********']"))); | |
| new WebDriverWait(driver, 5) | |
| .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("**********"))); |
People
:bowtie: |
π :smile: |
π :laughing: |
|---|---|---|
π :blush: |
π :smiley: |
:relaxed: |
π :smirk: |
π :heart_eyes: |
π :kissing_heart: |
π :kissing_closed_eyes: |
π³ :flushed: |
π :relieved: |
π :satisfied: |
π :grin: |
π :wink: |
π :stuck_out_tongue_winking_eye: |
π :stuck_out_tongue_closed_eyes: |
π :grinning: |
π :kissing: |
π :kissing_smiling_eyes: |
π :stuck_out_tongue: |
#Getting Started
##Webpage:
<html>
<head>
<title>Testing with Ruby and Selenium WebDriver</title>
</head>
<body bgcolor="antiquewhite">