Selenium WebDriver Quick Reference - sonnettest/TestAutomation GitHub Wiki
Use Javascript instead of Findelement method
JavascriptExecutor js = (JavascriptExecutor) driver;
`// Radio button`
`js.executeScript("$('#chkOneWay').click();");`
`//Check Box`
`js.executeScript("$('#ExtraBaggageAgreement').click()");`
`//Button`
`js.executeScript("$('.button.qSubmit.qValidate>span').click()");`
`//Text Box`
`js.executeScript("$('.searchInput').sendKeys('flights');");`
`// equivalent to driver.findElement(By.id("objId"))`
`js.executeScript("return document.getElementById('objId');");`
`JavascriptExecutor executor = (JavascriptExecutor)driver;`
`executor.executeScript("arguments[0].click();", element);`
`JavascriptExecutor jse = (JavascriptExecutor)driver;`
`jse.executeScript("document.getElementById('gbqfb').click();");`
`(String)js.executeScript("return document.readyState");`
`(String)js.executeScript("return document.title"); `
`(String) ((JavascriptExecutor) driver).executeScript("return window.jsErrors");`
`(String)js.executeScript("return document.URL"); `
Workaround for dropdowns
Selecting partial value.
driver.findElement(By.id("city")).findElement(By.cssSelector("option[value*='Chennai']")).click();
Selecting full value
new Select(driver.findElement(By.id("city"))).selectByValue("City: Chennai");
Selecting partial text.
driver.findElement(By.id("city")).findElement(By.xpath("//option[contains(text(),'Hyd')]")).click();