Here are some useful tips for Chrome Devtools.
I got this from one of my coleagues. Thanks Calin :)
http://anti-code.com/devtools-cheatsheet/
Have fun!
Wednesday, November 28, 2012
Tuesday, November 20, 2012
Selenium Server Setup
Steps to Setup Selenium Server:
1. Download and Install Java if not available.
http://www.java.com/en/download/index.jsp
2. Download Selenium Server.
http://seleniumhq.org/download/
3. Open Command Prompt in Selenium Server location and run the following command:
java -jar "selenium-server-standalone-2.25.0.jar"
4. In VisualStudio:
IWebDriver driver =
new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.Firefox());
1. Download and Install Java if not available.
http://www.java.com/en/download/index.jsp
2. Download Selenium Server.
http://seleniumhq.org/download/
3. Open Command Prompt in Selenium Server location and run the following command:
java -jar "selenium-server-standalone-2.25.0.jar"
4. In VisualStudio:
IWebDriver driver =
new RemoteWebDriver(new Uri("http://127.0.0.1:4444/wd/hub"),
DesiredCapabilities.Firefox());
Get XPath using Firefox Firebug
Selenium Webdriver Basics
Some basic Selenium WebDriver stuff:
1. Click a RadioButton:
var radioButton = driver.FindElements(By.Name("colorname"))[0];
radioButton.Click();
2. Get a RadioButton value:
var radioButtons = driver.FindElements(By.Name("colorname"));
foreach (var radioButton in radioButtons)
{
if (radioButton.Selected)
Console.WriteLine(radioButton.GetAttribute("value"));
}
3. Check Checkbox:
var checkBox = driver.FindElement(By.Id("checkboxId"));
checkBox.Click();
4. Select from dropdown list:
var select = driver.FindElement(By.Id("elementId"));
var option = select.FindElemets(By.TagName("optionTagName"))[0];
option.Click();
5. Get text row from table:
var table = driver.FindElement(By.TagName("table"));
var row = table.FindElements(By.TagName("td"))[0];
Console.WriteLine(row.Text);
6. Get element using XPath:
var element = driver.FindElement(By.XPath("//*[@id="gbqfq"]"));
7. Implicit waiting:
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
8. Explicit waiting:
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
var element = wait.Until(d=>
{
return driver.FindElements(By.ClassName("class"))[0];
});
element.Click();
1. Click a RadioButton:
var radioButton = driver.FindElements(By.Name("colorname"))[0];
radioButton.Click();
2. Get a RadioButton value:
var radioButtons = driver.FindElements(By.Name("colorname"));
foreach (var radioButton in radioButtons)
{
if (radioButton.Selected)
Console.WriteLine(radioButton.GetAttribute("value"));
}
3. Check Checkbox:
var checkBox = driver.FindElement(By.Id("checkboxId"));
checkBox.Click();
4. Select from dropdown list:
var select = driver.FindElement(By.Id("elementId"));
var option = select.FindElemets(By.TagName("optionTagName"))[0];
option.Click();
5. Get text row from table:
var table = driver.FindElement(By.TagName("table"));
var row = table.FindElements(By.TagName("td"))[0];
Console.WriteLine(row.Text);
6. Get element using XPath:
var element = driver.FindElement(By.XPath("//*[@id="gbqfq"]"));
7. Implicit waiting:
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
8. Explicit waiting:
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
var element = wait.Until(d=>
{
return driver.FindElements(By.ClassName("class"))[0];
});
element.Click();
Subscribe to:
Posts (Atom)