Selenium Notes
Selenium Notes
Reason being : WebDriver is an interface , and all its methods are used to automate
the UI are strongly implemented by ChromeDriver object.
Reason of using the chromewebdriver.exe : due to security reasons , an internal api
cannot call the external webbrowser, it needs some kind of exe to invoke and
communicate with the browser.
Types of locators :
1) Name.
2) Css.
3) xpath.
4) ID.
5) ClassName.
methods findElement(By.ID())
not every elemet are having the ID , ClassName or name - Xpath and CSS prefered.
Xpath :
Custom Xpath
$x()(in console)(xpath)
$()(css)
Xpath Syntax:
//tagName[@attribute='value']
//button[@name='login']
driver.findElement(By.cssSelector())
tagName[attribute='value'] - css
tagName[attribute='value'] - css
tagName#id
tagName.classname (avoid compound className)
<input name="username123">
//input[contains(@attribute,'value')]
input[Attribute='value']
//div[@class='lst-c']/div/div[2]/div/input
//div[@class='lst-c']/div/div[2]/div/input
//div[@class='rt-tr -odd']/div/div[2]/div/span/a
//div[@class='rt-tr-group']/div/div[2]/div/span[@id='see-book-Learning JavaScript
Design Patterns']
//"[text()=' ']
"//h4/a[]
www.qaclickacademy.com/interview.php
//li[@id='tablist-tab1']/following-sibling::li[3]
//li[@id='tablist-tab1']/parent::ul
//li[@role='tab']/following-sibling::li[4]
//li[@role='tab']/
//li[@aria-labelledby='ui-id-3']/parent::ul
//label[contains(text(),'Email or mobile phone number')]
//a[contains(text(),'Headlines')]
//a[Contains(text(),'Chennai')
//h2[@class='oOr8M uP1HId Ir3o3e cS3HJf']
//Compunding class rule is not applicable in case of xpath etc . only that rule is
applicable to By.findElementByClassName();
objChrome.isEnabled();
findEelemets() ;
types of wait :
Implecit wait
Explicit wait
Thread.sleep
Fluent wait
objChrome.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
Change the view from debugging to pakage explorer view / soulution explorer view ;
there is a table symbol on the left most to corner and click on that .
there will be java click on that the pakage explorer will get opened.
get windows handle uses to swicth between the tabs of the browser.
Using Actions (class in selenium one can automate the sendkeys and the right
click )
driver.switchTo().frame("child frame")
String clickonlinkTab=Keys.chord(Keys.CONTROL,Keys.ENTER);