SlideShare a Scribd company logo
1 of 26
Web Testi
Nedir? Gerekli midir? Zor mudur?
• Nedir: Test her çalıştığında web uygulamayı kullanıcı gibi suradaki
textbox nesnesini doldur buradaki butona bas. X yere gitti veya y
sonuç verdi ise test başırılıdır değil ise hatalıdır diye raporlayan araçtır.
• Gerekli mi:Testler geliştiriciler için gereksiz gibi gelir ancak varlıkları ile
erken hata tespiti ve «bir yeri yaptım , bir yer bozuldu» döngüsünden
bizi kurtar. Zaman kazandırır
• Zor mu: Hayır  örnek ile göreceğiz.
Selenium
• Nedir: Selenium ücretsiz,açık kaynak kodlu, web uygulamalarının test etmek için
oluşturulmuş kütüphanedir. 2004 yılında Jason Huggins (ThoughtWorks) abimiz
"fast, fast, fast." baskısından sıkılıp tekrar eden işleri farklı tarayıcılarda
gerçekleştirmek için geliştirdiği javascript temelli farkli dillere api leri bulunan
kütüpane.
• Selenium için bazıları cross browser test aracı dese de aslında yaptığı şey bir web
uygulaması kullanıcısının hareketlerini otomatize etme
• Dört ana bileşenini bulunmaktadir. Selenium IDE, Selenium GRID ,Selenium
remote Control ve Selenium Web Driver.
Selenium IDE
• Kullanması en kolay Selenium bileşenidir
• Aslında bir firefox eklentisidir.
• Herhangi bir kod yazmadan test gerçekleştir
• Record tuşu ile testi otomatik oluşturabileceğimiz
gibi command,target,value kısımlarını ile
seçerek de oluşturabiliriz
• Hızlı test olusturmak için ideal
• Sadece firefox desteği mevcut
• C#, Java , ruby ... İçin export mevcut
Örnek 1
Selenium Grid ve Remote Control
• Selenium Grid: Test senaryolarımızı farklı
ayarlar ile paralel olarak çalıştırmıza olana
veren bileşenidir.
• Selenium Remote Control ise uzak testler
gerçekleştibilmemizi sağlayan bileşen.
• Selenium Grid+Remote control ile paralel
ve remote testler gerçekleştirerek güzel bir
comboya imza atmış oluyoruz.
Selenium Web Driver
• Test senaryolarımızı Java , ruby , python ve c# gibi bir çok dilde
kodlayarak yazabileceğimiz nunit , xunit gibi birim testleri ile de
eşleştirebileceğimiz kodlarımızı lokal makinemizde çeşitli tarayıcılarda
çalıştırabildiğimiz selenium bileşenidir.
• Programlanarak ve debug edilerek kullanıldığı ve unit testleri ile
kullanılabildiği için benim favorim.
• Çoklu tarayıcı desteği. (firefox,safari,chrome,Internet Explorer)
Komutlar
• Sayfa Komutları (Sayfaya git, Refresh ...)
• Element Komutlar (value gir, value oku,click ..)
• Doğrulama Komutları
Element Secici/Bulucu Türleri (Locator)
• ClassName
• CssSelector
• Id
• LinkText
• Name
• PartialLinkText(string partialLinkTextToFind);
• TagName(string tagNameToFind);
• XPath(string xpathToFind);
ClassName ile seçim
HTML
<div class="cheese"><span>Cheddar</span></div>
<div class="cheese"><span>Gouda</span></div>
C#
IList<IWebElement> cheeses =
driver.FindElements(By.ClassName("cheese"));
ID ile seçim
HTML
<div id="coolestWidgetEvah">...</div>
C#
IWebElement element =
driver.FindElement(By.Id("coolestWidgetEvah"));
Name ile seçim
HTML
<input name="cheese" type="text"/>
C#
IWebElement element =
driver.FindElement(By.Name("cheese"));
Link Text ile seçim
HTML
<a href="http://google.com/search?q=cheese">
cheese</a>
C#
IWebElement element =
driver.FindElement(By.LinkText("cheese"));
Partial Link Text ile seçim
HTML
<a href="http://google.com/search?q=cheese">
search for cheese</a>
C#
IWebElement element =
driver.FindElement(By.PartialLinkText("cheese"));
Css Selector ile seçim
HTML
<div id="food">
<span class="dairy">milk</span>
<span class="dairy aged">cheese</span>
</div>
C#
IWebElement element =
driver.FindElement(
By.CssSelector("#food span.dairy.aged"));
XPath ile seçim
HTML
<input type="text" name="example" />
<INPUT type="text" name="other" />
C#
IWebElement element =
driver.FindElement(
By.CssSelector("#food span.dairy.aged"));
Selectorlar yetmedi ise Javascript Executor
Örnek 1
IWebElement element = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript("return $('.cheese')[0]");
Örnek 2
IList<IWebElement> labels = driver.FindElements(By.TagName("label"));
IList<IWebElement> inputs = (IList<IWebElement>)((IJavaScriptExecutor)driver).ExecuteScript(
"var labels = arguments[0], inputs = []; for (var i=0; i < labels.length; i++){" +
"inputs.push(document.getElementById(labels[i].getAttribute('for'))); } return inputs;", labels);
Ufak bir detay Explicit and Implicit Waits
Testler oluştururken en çok hatayı element henüz hazır değil,sayfa henüz
yüklenmemiş ise alıyoruz. Gerek internet hızı, gerek javacriptin kontrolleri
dönüştürmesi sebebi ile bazen beklememiz gerekiyor.
Implicit Wait: Webdriver a elementi dom dan seçmesi için verebileceğimi timeout değeri
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); ile belirlenir
Explicit Wait: Webdriver a timeout süresi kadar her 500 milisaniyede bir tekrar denemesinı sağlayan
yapı. Page reload olduğu veya ajax ile veri beklediğimiz anlarda candır.
var element = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("someid")));
Örnek 2
Programatik Yazılmış Web testi
Örnek 3
Selenium ide den Export
SpectFlow
Örnek 4
SpeckFlow
Selenium.Support
• Bu kütüphane ile daha okunaklı (readable) ve daha sürdürülebilir
(maintainable) selenium kodları yazmak mümkün.
İlgili güzel teknolojiler
• Seleno (Asp.net Mvc için özelleştirilmiş Strongly typed gibi özellikleri
de bulunan selenium destekli test kütüpanesi)
• Telerik Test Framework 2016.1
• MS Coded UI
• Continuous integration ile Testleri çoklu hale getirme.
Kaynak
• http://www.seleniumhq.org/
• http://googletesting.blogspot.com.tr/2007/09/seleniums-inventor.html
• http://www.firatdogan.net/post/124228808606/selenium-1-2-webdriver-ve-grid
• http://www.slideshare.net/yuxel/selenium-14821101
SON

More Related Content

What's hot

Test Automation - Keytorc Approach
Test Automation - Keytorc Approach Test Automation - Keytorc Approach
Test Automation - Keytorc Approach
Keytorc Software Testing Services
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
Raghu Kiran
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
Yogindernath Gupta
 

What's hot (20)

50 Soruda Yazılım Testi
50 Soruda Yazılım Testi50 Soruda Yazılım Testi
50 Soruda Yazılım Testi
 
Test Mühendisliğine Giriş Eğitimi - Bölüm 1
Test Mühendisliğine Giriş Eğitimi - Bölüm 1Test Mühendisliğine Giriş Eğitimi - Bölüm 1
Test Mühendisliğine Giriş Eğitimi - Bölüm 1
 
End to end test automation with cypress
End to end test automation with cypressEnd to end test automation with cypress
End to end test automation with cypress
 
Component testing with cypress
Component testing with cypressComponent testing with cypress
Component testing with cypress
 
Introduction to Test Automation
Introduction to Test AutomationIntroduction to Test Automation
Introduction to Test Automation
 
Automation testing on ios platform using appium
Automation testing on ios platform using appiumAutomation testing on ios platform using appium
Automation testing on ios platform using appium
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
 
ISTQB Foundation Level Basic
ISTQB Foundation Level BasicISTQB Foundation Level Basic
ISTQB Foundation Level Basic
 
Test Automation - Keytorc Approach
Test Automation - Keytorc Approach Test Automation - Keytorc Approach
Test Automation - Keytorc Approach
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
 
Browser_Stack_Intro
Browser_Stack_IntroBrowser_Stack_Intro
Browser_Stack_Intro
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
 
Unit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and KarmaUnit testing in JavaScript with Jasmine and Karma
Unit testing in JavaScript with Jasmine and Karma
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Test automation wipro
Test automation   wiproTest automation   wipro
Test automation wipro
 
Automated testing with Cypress
Automated testing with CypressAutomated testing with Cypress
Automated testing with Cypress
 
Cypress testing
Cypress testingCypress testing
Cypress testing
 
Test Automation
Test AutomationTest Automation
Test Automation
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 

Similar to Selenium ile Web testi.

Caylak Javacilara Yol Haritasi
Caylak Javacilara Yol HaritasiCaylak Javacilara Yol Haritasi
Caylak Javacilara Yol Haritasi
mehmetbicak
 
Caylak Javacilara Yol Haritasi
Caylak Javacilara Yol HaritasiCaylak Javacilara Yol Haritasi
Caylak Javacilara Yol Haritasi
mehmetbicak
 
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleriVisual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
Murat Başeren
 

Similar to Selenium ile Web testi. (20)

Selenium
SeleniumSelenium
Selenium
 
Jest ile JavaScript Testleri
Jest ile JavaScript TestleriJest ile JavaScript Testleri
Jest ile JavaScript Testleri
 
Web İçin Teknoloji Geliştirmek
Web İçin Teknoloji GeliştirmekWeb İçin Teknoloji Geliştirmek
Web İçin Teknoloji Geliştirmek
 
Java Web Uygulama Geliştirme
Java Web Uygulama GeliştirmeJava Web Uygulama Geliştirme
Java Web Uygulama Geliştirme
 
Django nedir
Django nedirDjango nedir
Django nedir
 
Zed attack-proxy-web
Zed attack-proxy-webZed attack-proxy-web
Zed attack-proxy-web
 
Çevik testler
Çevik testlerÇevik testler
Çevik testler
 
Caylak Javacilara Yol Haritasi
Caylak Javacilara Yol HaritasiCaylak Javacilara Yol Haritasi
Caylak Javacilara Yol Haritasi
 
Caylak Javacilara Yol Haritasi
Caylak Javacilara Yol HaritasiCaylak Javacilara Yol Haritasi
Caylak Javacilara Yol Haritasi
 
Radore Workshop: Wordpress Nereye Koşuyor?
Radore Workshop: Wordpress Nereye Koşuyor? Radore Workshop: Wordpress Nereye Koşuyor?
Radore Workshop: Wordpress Nereye Koşuyor?
 
Go ile Hızlı Web Uygulamaları
Go ile Hızlı Web UygulamalarıGo ile Hızlı Web Uygulamaları
Go ile Hızlı Web Uygulamaları
 
jQuery ile ASP.NET Uygulamaları Geliştirme
jQuery ile ASP.NET Uygulamaları GeliştirmejQuery ile ASP.NET Uygulamaları Geliştirme
jQuery ile ASP.NET Uygulamaları Geliştirme
 
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleriVisual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
Visual studio 2010 ve tfs 2010 yeni takim gelistirme ozellikleri
 
Jenkins
JenkinsJenkins
Jenkins
 
JVM Tuning and Monitoring, JVM Languages, IDE
JVM Tuning and Monitoring, JVM Languages, IDEJVM Tuning and Monitoring, JVM Languages, IDE
JVM Tuning and Monitoring, JVM Languages, IDE
 
Devops Kime Lazım? Neden Lazım?
Devops Kime Lazım? Neden Lazım?Devops Kime Lazım? Neden Lazım?
Devops Kime Lazım? Neden Lazım?
 
Kayıp Yaşamadan Site Geçişi (Migration) için Altın Noktalar
Kayıp Yaşamadan Site Geçişi (Migration) için Altın NoktalarKayıp Yaşamadan Site Geçişi (Migration) için Altın Noktalar
Kayıp Yaşamadan Site Geçişi (Migration) için Altın Noktalar
 
IstanbulPHP meetup sunum
IstanbulPHP meetup sunumIstanbulPHP meetup sunum
IstanbulPHP meetup sunum
 
PHPUnit ve Laravel
PHPUnit ve LaravelPHPUnit ve Laravel
PHPUnit ve Laravel
 
Go Programlama Dili - Seminer
Go Programlama Dili - SeminerGo Programlama Dili - Seminer
Go Programlama Dili - Seminer
 

Selenium ile Web testi.

  • 2. Nedir? Gerekli midir? Zor mudur? • Nedir: Test her çalıştığında web uygulamayı kullanıcı gibi suradaki textbox nesnesini doldur buradaki butona bas. X yere gitti veya y sonuç verdi ise test başırılıdır değil ise hatalıdır diye raporlayan araçtır. • Gerekli mi:Testler geliştiriciler için gereksiz gibi gelir ancak varlıkları ile erken hata tespiti ve «bir yeri yaptım , bir yer bozuldu» döngüsünden bizi kurtar. Zaman kazandırır • Zor mu: Hayır  örnek ile göreceğiz.
  • 3. Selenium • Nedir: Selenium ücretsiz,açık kaynak kodlu, web uygulamalarının test etmek için oluşturulmuş kütüphanedir. 2004 yılında Jason Huggins (ThoughtWorks) abimiz "fast, fast, fast." baskısından sıkılıp tekrar eden işleri farklı tarayıcılarda gerçekleştirmek için geliştirdiği javascript temelli farkli dillere api leri bulunan kütüpane. • Selenium için bazıları cross browser test aracı dese de aslında yaptığı şey bir web uygulaması kullanıcısının hareketlerini otomatize etme • Dört ana bileşenini bulunmaktadir. Selenium IDE, Selenium GRID ,Selenium remote Control ve Selenium Web Driver.
  • 4. Selenium IDE • Kullanması en kolay Selenium bileşenidir • Aslında bir firefox eklentisidir. • Herhangi bir kod yazmadan test gerçekleştir • Record tuşu ile testi otomatik oluşturabileceğimiz gibi command,target,value kısımlarını ile seçerek de oluşturabiliriz • Hızlı test olusturmak için ideal • Sadece firefox desteği mevcut • C#, Java , ruby ... İçin export mevcut
  • 6. Selenium Grid ve Remote Control • Selenium Grid: Test senaryolarımızı farklı ayarlar ile paralel olarak çalıştırmıza olana veren bileşenidir. • Selenium Remote Control ise uzak testler gerçekleştibilmemizi sağlayan bileşen. • Selenium Grid+Remote control ile paralel ve remote testler gerçekleştirerek güzel bir comboya imza atmış oluyoruz.
  • 7. Selenium Web Driver • Test senaryolarımızı Java , ruby , python ve c# gibi bir çok dilde kodlayarak yazabileceğimiz nunit , xunit gibi birim testleri ile de eşleştirebileceğimiz kodlarımızı lokal makinemizde çeşitli tarayıcılarda çalıştırabildiğimiz selenium bileşenidir. • Programlanarak ve debug edilerek kullanıldığı ve unit testleri ile kullanılabildiği için benim favorim. • Çoklu tarayıcı desteği. (firefox,safari,chrome,Internet Explorer)
  • 8. Komutlar • Sayfa Komutları (Sayfaya git, Refresh ...) • Element Komutlar (value gir, value oku,click ..) • Doğrulama Komutları
  • 9. Element Secici/Bulucu Türleri (Locator) • ClassName • CssSelector • Id • LinkText • Name • PartialLinkText(string partialLinkTextToFind); • TagName(string tagNameToFind); • XPath(string xpathToFind);
  • 10. ClassName ile seçim HTML <div class="cheese"><span>Cheddar</span></div> <div class="cheese"><span>Gouda</span></div> C# IList<IWebElement> cheeses = driver.FindElements(By.ClassName("cheese"));
  • 11. ID ile seçim HTML <div id="coolestWidgetEvah">...</div> C# IWebElement element = driver.FindElement(By.Id("coolestWidgetEvah"));
  • 12. Name ile seçim HTML <input name="cheese" type="text"/> C# IWebElement element = driver.FindElement(By.Name("cheese"));
  • 13. Link Text ile seçim HTML <a href="http://google.com/search?q=cheese"> cheese</a> C# IWebElement element = driver.FindElement(By.LinkText("cheese"));
  • 14. Partial Link Text ile seçim HTML <a href="http://google.com/search?q=cheese"> search for cheese</a> C# IWebElement element = driver.FindElement(By.PartialLinkText("cheese"));
  • 15. Css Selector ile seçim HTML <div id="food"> <span class="dairy">milk</span> <span class="dairy aged">cheese</span> </div> C# IWebElement element = driver.FindElement( By.CssSelector("#food span.dairy.aged"));
  • 16. XPath ile seçim HTML <input type="text" name="example" /> <INPUT type="text" name="other" /> C# IWebElement element = driver.FindElement( By.CssSelector("#food span.dairy.aged"));
  • 17. Selectorlar yetmedi ise Javascript Executor Örnek 1 IWebElement element = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript("return $('.cheese')[0]"); Örnek 2 IList<IWebElement> labels = driver.FindElements(By.TagName("label")); IList<IWebElement> inputs = (IList<IWebElement>)((IJavaScriptExecutor)driver).ExecuteScript( "var labels = arguments[0], inputs = []; for (var i=0; i < labels.length; i++){" + "inputs.push(document.getElementById(labels[i].getAttribute('for'))); } return inputs;", labels);
  • 18. Ufak bir detay Explicit and Implicit Waits Testler oluştururken en çok hatayı element henüz hazır değil,sayfa henüz yüklenmemiş ise alıyoruz. Gerek internet hızı, gerek javacriptin kontrolleri dönüştürmesi sebebi ile bazen beklememiz gerekiyor. Implicit Wait: Webdriver a elementi dom dan seçmesi için verebileceğimi timeout değeri driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); ile belirlenir Explicit Wait: Webdriver a timeout süresi kadar her 500 milisaniyede bir tekrar denemesinı sağlayan yapı. Page reload olduğu veya ajax ile veri beklediğimiz anlarda candır. var element = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("someid")));
  • 20. Örnek 3 Selenium ide den Export
  • 23. Selenium.Support • Bu kütüphane ile daha okunaklı (readable) ve daha sürdürülebilir (maintainable) selenium kodları yazmak mümkün.
  • 24. İlgili güzel teknolojiler • Seleno (Asp.net Mvc için özelleştirilmiş Strongly typed gibi özellikleri de bulunan selenium destekli test kütüpanesi) • Telerik Test Framework 2016.1 • MS Coded UI • Continuous integration ile Testleri çoklu hale getirme.
  • 25. Kaynak • http://www.seleniumhq.org/ • http://googletesting.blogspot.com.tr/2007/09/seleniums-inventor.html • http://www.firatdogan.net/post/124228808606/selenium-1-2-webdriver-ve-grid • http://www.slideshare.net/yuxel/selenium-14821101
  • 26. SON