Grow Together Mentors Inspire Us In Life

Internet

Technology

Gadgets

Latest Release

Tuesday, July 21, 2015

The Siplest way to set proxy settings

Firefox:
String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
IWebDriver driver = new FirefoxDriver(cap);

IE & Chrome - Chrome will take same cofiguration what IE uses

String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);

IWebDriver driver = new InternetExplorerDriver(cap);


The Simplest way to set proxy settings

Firefox:
String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);

IE & Chrome - Chrome will take same cofiguration what IE uses

String PROXY = "localhost:8080";

org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
     .setFtpProxy(PROXY)
     .setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new InternetExplorerDriver(cap);


The Advanced User Interactions require native events to be enabled. Here’s a table of the current support Matrix for native events:
platformIE6IE7IE8IE9FF3.6FF10+Chrome stableChrome betaChrome devOperaAndroidiOS
Windows XPYYYn/aYYYYY?[1]n/a
Windows 7n/an/aYYYYYYY?[1]n/a
Linux (Ubuntu)n/an/an/an/a[2][2]YYY?[1]n/a
Mac OSXn/an/an/an/aNNYYY?[1]N
Mobile Devicen/an/an/an/an/a?n/an/an/a?YN
[1](1234) Using the emulator
[2](12) With explicitly enabling native events




Monday, July 13, 2015

Use following simple method to get Id attribute using XPath,

public string GetIDxpath(string xPath)
        {
            string id = driver.findElement(By.XPath(@" + xPath + @")).GetAttribute("id");
            return id;
        }
Use following generic method to get list of descendent elements using XPath

public List<WebElement> FindDescendentsXPath(WebElement objectName)
        {
            List<WebElement> descendents = objectName.findElements(By.XPath(".//*"));
            return descendents;
        }
Use following generic method to get list of descendent elements using XPath

public IList<IWebElement> FindDescendentsXPath(IWebElement objectName)
        {
            IList<IWebElement> descendents = objectName.FindElements(By.XPath(".//*"));
            return descendents;
        }
Use following generic method for get child XPath

public static string FindChildXPath(string element)
        {
            string childXpath = "//[@id='" + element + "']/" + element[1] + "/";
            return childXpath;
        }