Selenium is a high quality open source test automation tool for web application testing . السيلنيوم من جودة عالية المصادر المفتوحه للتجارب التشغيل الآلي اداة لتطبيق الاختبار على الشبكه العالمية. Selenium runs in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh, Safari on the Mac, with plans to support Safari on iPhone soon. ويدير السيلنيوم في انترنت اكسبلورر ، وموزيلا فايرفوكس على أنظمة ويندوز ، لينكس ، وماكنتوش ، سفاري على لجنة الهدنه العسكرية ، مع خطط لدعم سفاري على اي فون قريبا. Selenium test scripts are portable, can be run from browsers (using Selenium IDE) or from JUNit or NGUnit (using Selenium RC) etc.. السيلنيوم اختبار مخطوطات محمولة ، ويمكن تشغيلها من المتصفحات (باستخدام السيلنيوم بيئة تطوير متكاملة) او من JUnit او ngunit (باستخدام السيلنيوم اتفاقيه روتردام) وما شابه ذلك. For example, test scripts written using Selenium IDE in Firefox on Windows can run on Firefox in Mac or Linux, without changing any code. فعلى سبيل المثال ، باستخدام اختبار المخطوطات المكتوبة السيلنيوم بيئة تطوير متكاملة في فايرفوكس على النوافذ التي يمكن تشغيلها على فايرفوكس في نظام ماكنتوش أو لينكس ، لم يتغير اي قانون. Selenium tests run directly in browsers and so matches the end-user experience closely. السيلنيوم التحاليل التي اجريت مباشرة في المتصفحات وحتى مباريات المستعمل التجربه عن كثب.

There are three variants of Selenium, which can be used in isolation or in combination to create complete automation test suite for your web applications. وهناك ثلاثة بدائل من السيلنيوم ، والتي يمكن استخدامها في عزلة او في توليفة لانشاء جناح للتجارب التشغيل الآلي الكامل لتطبيقات الويب الخاص بك.

  • Selenium Core - In Selenium Core the tests scripts (written in HTML) and the Selenium Test Runner (written in Javascript) are uploaded to the same web server that hosts the application you are trying to test. السيلنيوم الاساسية -- السيلنيوم الاساسية في الاختبارات مخطوطات (مكتوب في لغة تأشير النص الفائق) والسيلنيوم اختبار عداء (كتب في جافا سكريبت) هي نفسها التي تم تحميلها على خادم الويب التي تستضيف تطبيق انت تحاول اختبار. It is a simpler form of Selenium, and suitable for non-developers, but it has some inherent limitations. ومن ابسط شكل من اشكال السيلنيوم ، وغير مناسبة للمطورين ، لكنه أضاف ان بعض اوجه القصور المتاصله.

  • Selenium IDE - Selenium IDE is a Firefox plugin, which includes the entire Selenium Core, allows you to record, play back, edit, and debug tests in browser. بيئة تطوير متكاملة السيلنيوم -- السيلنيوم بيئة تطوير متكاملة فايرفوكس هو البرنامج المساعد ، الذي يشمل كامل السيلنيوم الاساسية ، يسمح لك أن تسجل ، مسرحيه العودة ، تحرير ، وتصحيح التجارب في المتصفح. It provides the simplest introduction to Selenium and is highly recommended for beginners. وهو يوفر ابسط مقدمة لوالسيلنيوم ويوصي بشدة للمبتدئين. You can save the tests / test suite created in xml or html format. يمكنك ان توفر الاختبارات / اختبار لغة الترميز القابلة للامتداد الجناح الذي انشئ في شكل او لغة تأشير النص الفائق. However to run them in an automated fashion you need Selenium Remote Control which is described next. ولكن لتشغيل تلك مءتمته تحتاج السيلنيوم بطريقة التحكم عن بعد الذي وصفه المقبل.

  • Selenium Remote Control - The Selenium Remote Control allows you to develop test cases and test suites in Java (supports JUnit & NGUnit), PHP, Ruby, Python, Perl and even .NET. السيلنيوم التحكم عن بعد -- السيلنيوم يتيح لك التحكم عن بعد لتطوير واختبار حالات الاختبار اجنحه في يافا (يدعم JUnit & ngunit) ، بي. اتش. بى ، روبي ، بايثون ، بيرل ، بل و. صافي. It is the most flexible setup but requires some development knowledge to set up and use. وهو اكثر مرونة الاعداد لكنها تحتاج الى بعض المعرفه في التنمية لانشاء واستخدامها.

  • Selenium Grid - Selenium Grid allows several Selenium Remote Control servers to be accessed in parallel by Selenium Grid server. السيلنيوم الشبكه -- السيلنيوم الشبكه تتيح عدة السيلنيوم التحكم عن بعد لخدمة الوصول السيلنيوم متوازيه من جانب خادم الشبكه. This is extremely useful for automated load and stress testing of web applications. وهذا امر مفيد للغاية لتحميل الآلي واختبار الاجهاد من التطبيقات الشبكيه.



Today we will discuss on how you can easily create automatic test scripts using Selenium IDE and convert them to JUnit tests (which uses Selenium Remote Control) which can be added to your JUnit based automatic regression test suite. وسوف نناقش اليوم بشأن كيفية فيمكنك بسهولة انشاء التلقائي للتجارب باستخدام برمجيه السيلنيوم بيئة تطوير متكاملة وتحويلها الى JUnit التجارب (والذي يستخدم السيلنيوم التحكم عن بعد) التي يمكن ان تضاف الى القائمة الخاصة بك تلقائيا JUnit الانحدار اختبار الجناح.

How to create a test plan in Selenium IDE كيفية انشاء وحدة للتجارب في خطة السيلنيوم بيئة تطوير متكاملة


Creating a test plan in Selenium IDE is very easy, so we will use it to create few simple tests to begin with. ايجاد خطة الاختبار السيلنيوم في بيئة تطوير متكاملة من السهل جدا ، حتى اننا سوف نستخدمه لانشاء الاختبارات البسيطة اصلا.

  • Install تثبيت Selenium IDE 0.8.7 السيلنيوم 0.8.7 بيئة تطوير متكاملة , a Firefox plugin. ، فايرفوكس البرنامج المساعد.

  • After installing Selenium please restart your Firefox browser for the plugin to be activated. بعد تثبيت السيلنيوم يرجى اعادة تشغيل المتصفح فايرفوكس ليتم تنشيط البرنامج المساعد ل.

  • Now you should see a new added menu item named Selenium IDE under your Firefox Tools menu. الآن يجب ان تتمكن من رؤية جديدة واضاف فهرس اسمه السيلنيوم بيئة تطوير متكاملة في ظل قيادتكم القائمة ادوات فايرفوكس.

  • Open / browse the site for which you want to prepare a test case. فتح / تصفح الموقع الذي تريد ان تعد حالة اختبار.

  • Start Selenium IDE from Firefox Tools->Selenium IDE . بدء السيلنيوم بيئة تطوير متكاملة من الأدوات فايرفوكس -> السيلنيوم بيئة تطوير متكاملة.

  • Browse some pages. استعرض بعض الصفحات.

  • Now click red button to stop recording. الآن انقر على الزر الاحمر لايقاف التسجيل.


At this point you will see Selenium automatically recording your actions. وعند هذه النقطه سوف ترى السيلنيوم تسجيل الاجراءات الخاصة بك تلقائيا. Carefully note the commands, target and value. ملاحظه الاوامر بعناية ، والهدف والقيمه. You can create and insert your own commands/ modify or even delete them. يمكنك انشاء وتدرج الاوامر الخاصة بك / أو تعديل أو حتى حذفها. We will show some examples below. سنعرض فيما يلي بعض الامثله. In the next section we will see how we can modify the generated tests to suit our needs. في الجزء التالي سوف نرى كيف يمكننا ان تولد التجارب تعديل لتتناسب مع احتياجاتنا.

How to create / modify / delete Selenium commands كيفية انشاء / تعديل او حذف السيلنيوم الاوامر


The default commands generated by Selenium when you are browsing the page as a normal user should be modified to make the test more robust and to add test cases to it. الافتراضي الاوامر التي تولدها السيلنيوم عند تصفحك للصفحة مستخدم عادي وينبغي تعديلها لجعل الاختبار اكثر قوة واضافة الى حالات الاختبار.

  • Let's replace all click commands by clickAndWait . click simply clicks the specified link and goes on to execute the next command without waiting. ولتحل محل جميع الاوامر عن طريق النقر clickandwait. ببساطة انقر نقرات المحدد صلة ويمضي لتنفيذ المقبل القيادة دون انتظار. On the other hand clickAndWait waits for the new page to loaded before executing the next command. clickAndWait should be used to make more robust test cases. ومن ناحية اخرى تنتظر clickandwait الصفحه الجديدة للتحميل قبل تنفيذ القادمة القيادة. Clickandwait ينبغي ان يستخدم لصنع اكثر قوة حالات الاختبار.

  • Insert assertTextNotPresent command after each clickAndWait command to confirm a text must not be present in the browsed page. تضاف asserttextnotpresent القيادة بعد كل clickandwait القيادة ان يؤكد النص لا يجب ان تكون موجودة في الصفحه تصفحها.

  • Use assertTextPresent command to confirm a text must be present in the browsed page. استخدام asserttextpresent القيادة للتأكد من نص يجب ان تكون موجودة في الصفحه تصفحها.

  • Finally to test your test plan please click green arrow button to play from the begining or to play from start point. واخيرا لاختبار خطة الاختبار الخاصة بك يرجى النقر على زر السهم الاخضر للعب من البداية أو تقوم به من نقطة البداية.

  • Export the test plan as java file by Selenium IDE File->Export Test As->Java - Selenium RC (for example the file name is SeleniumSTSanityTest.java ) الصادرات اختبار خطة جافا السيلنيوم بيئة تطوير متكاملة من جانب الملف - ملف> تصدير للاختبار -> جافا -- السيلنيوم اتفاقيه روتردام (على سبيل المثال اسم الملف هو seleniumstsanitytest.java)

  • Then close your Firefox Selenium ID. ثم اغلق فايرفوكس السيلنيوم الهوية الخاصة بك.



How to run above test plan (automatically generated java file from Selenium IDE) in command line? كيف تدير خطة الاختبار اعلاه (جافا الملف تلقائيا من السيلنيوم بيئة تطوير متكاملة) في سطر الاوامر؟

  • Download تنزيل Selenium RC السيلنيوم اتفاقيه روتردام .

  • Unzip it under the same directory where SeleniumSTSanityTest.java (exported test plan as java file from Selenium ID) was saved. Unzip انه في اطار نفس المجلد حيث seleniumstsanitytest.java (تصدير اختبار خطة جافا الملف من السيلنيوم الهوية) وانقذ.

  • Install junit. تثبيت JUnit.

  • Go to directory where you unzip selenium-remote-control-1.0-beta-1-dist.zip file. اذهب الى دليل اين unzip السيلنيوم - التحكم عن بعد - 1.0 - بيتا - 1 - dist.zip الملف.

  • Open a terminal and do the steps below- فتح محطة والقيام الخطوات الواردة ادناه -

    • cd selenium-remote-control-1.0-beta-1/selenium-server-1.0-beta-1 مؤتمر نزع السلاح selenium-remote-control-1.0-beta-1/selenium-server-1.0-beta-1

    • java -jar selenium-server.jar (to run the server in interactive mode execute java -jar selenium-server.jar -interactive) جرة جافا - السيلنيوم - server.jar) لتشغيل الخادم في الوضع التبادلي تنفيذ جرة جافا - السيلنيوم - server.jar تفاعليه)

    • If you get an error like Error: com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: sessionId should not be null; has this session been started yet? then ensure that the browser is in the PATH before running the server. اذا حصل خطأ مثل خطأ : com.thoughtworks.selenium.seleniumexception : خطأ خادم استثناء : sessionid لا ينبغي ان يكون لاغيا ؛ وقد بدأت هذه الدورة حتى الآن؟ ثم ضمان ان المتصفح هو في الطريق قبل تشغيل الخادم. For example, you want to run the test in Firefox. فعلى سبيل المثال ، كنت تريد تشغيل فايرفوكس في الاختبار. Then you should do next two steps. ثم عليك ان تفعل المقبل خطوتين.

    • locate firefox-bin (for example it returns /usr/lib/firefox-1.5.0.12/firefox-bin) - تحديد مكان بن لفايرفوكس (على سبيل المثال تعود / usr/lib/firefox-1.5.0.12/firefox-bin)

    • export PATH=$PATH:/usr/lib/firefox-1.5.0.12/firefox-bin; الصادرات الطريق دولار = المسار : / usr/lib/firefox-1.5.0.12/firefox-bin ؛
      Note: There is an alternative way to fix above error (browser is not in path). ملاحظه : هناك طريقة بديلة لتصحيح الخطأ أعلاه (المتصفح ليست في الطريق). Simply replace chrome with browser PATH in SeleniumSTSanityTest.java file. مجرد الاستعاضه عن طريق المتصفح مع الكروم في seleniumstsanitytest.java الملف. For example: فعلى سبيل المثال :
      line الخط
      setUp("http://blog.taragana.com", "*chrome"); الاعداد ( "http://blog.taragana.com" ، و "الكروم *") ؛
      becomes يصبح
      setUp("http://blog.taragana.com", "*firefox /usr/lib/firefox-1.5.0.12/firefox-bin"); الاعداد ( "http://blog.taragana.com" ، "* فايرفوكس / usr/lib/firefox-1.5.0.12/firefox-bin") ؛
      in SeleniumSTSanityTest.java . في seleniumstsanitytest.java.
      To run the test in opera browser replace chrome with opera . لخوض التجارب في الاوبرا متصفح الأوبرا مع استبدال الكروم.


    Now the selenium server is running and you have to run the Java client located in selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1. الآن السيلنيوم وتشغيل مركز الخدمة لديك لتشغيل جافا العملاء الموجودة في selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1.

  • Open another terminal. فتح محطة اخرى.

    • export CLASSPATH=.:selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1/selenium-java-client-driver.jar:/usr/share/java/junit.jar الصادرات classpath =. : selenium-remote-control-1.0-beta-1/selenium-java-client-driver-1.0-beta-1/selenium-java-client-driver.jar : / usr / حصة / جافا / JUnit. جرة

    • javac SeleniumSTSanityTest.java javac seleniumstsanitytest.java

    • java SeleniumSTSanityTest جافا seleniumstsanitytest




The automatically generated java file SeleniumSTSanityTest.java is likely to have some defects. وقد تلقائيا جافا الملف seleniumstsanitytest.java ويحتمل ان يكون لبعض الشوائب. Fix it by comparing with the example below: اصلاحها من خلال مقارنة مع المثال التالي :




import com.thoughtworks.selenium.*; استيراد com.thoughtworks.selenium *. ؛
import junit.framework.*; استيراد junit.framework *. ؛
import java.util.regex.Pattern; استيراد java.util.regex.pattern ؛

public class SeleniumSTSanityTest extends SeleneseTestCase { وتمتد الطبقة العامة seleniumstsanitytest (selenesetestcase
public void setUp() throws Exception { الاعداد لاغيه العامة () (باستثناء رميات
setUp("http://blog.taragana.com", "*chrome"); // to run the test in opera replace chrome with opera الاعداد ( "http://blog.taragana.com" ، و "الكروم *") ؛ / / لتشغيل يحل محل الإختبار في الاوبرا والأوبرا مع الكروم
} )
public void testSimpleThoughts() throws Exception { testsimplethoughts العامة لاغيه () (باستثناء رميات
selenium.open(""); selenium.open ("")؛
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertfalse (selenium.istextpresent ( "WordPress خطأ في قاعدة البيانات : ["))؛
assertTrue(selenium.isTextPresent("2003-2008")); asserttrue (selenium.istextpresent ( "2003-2008")) ؛
selenium.open("/index.php/category/programming/java"); selenium.open ( "/ index.php / الفئة / البرمجه / جافا") ؛
selenium.waitForPageToLoad("30000"); selenium.waitforpagetoload ( "30000") ؛
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertfalse (selenium.istextpresent ( "WordPress خطأ في قاعدة البيانات : ["))؛
assertTrue(selenium.isTextPresent("2003-2008")); asserttrue (selenium.istextpresent ( "2003-2008")) ؛
selenium.click("//img[@alt='Übersetzen Sie zum Deutsch/German']"); selenium.click ( "/ / img] @ البديل =' übersetzen Sie حركة وحدة بزيمبابوى المانى / الالمانيه ']")؛
selenium.waitForPageToLoad("30000"); selenium.waitforpagetoload ( "30000") ؛
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertfalse (selenium.istextpresent ( "WordPress خطأ في قاعدة البيانات : ["))؛
assertTrue(selenium.isTextPresent("2003-")); asserttrue (selenium.istextpresent ( "2003 -"))؛
selenium.click("//img[@alt='Přeložit do Čech/Czech']"); selenium.click ( "/ / img] @ البديل =' přeložit القيام čech / التشيكيه ']")؛
selenium.waitForPageToLoad("60000"); selenium.waitforpagetoload ( "60000") ؛
assertFalse(selenium.isTextPresent("WordPress database error: [")); assertfalse (selenium.istextpresent ( "WordPress خطأ في قاعدة البيانات : ["))؛
assertTrue(selenium.isTextPresent("2003")); asserttrue (selenium.istextpresent ( "2003")) ؛
} )

public static Test suite() { اختبار ساكنة العامة الجناح () (
return new TestSuite(SeleniumSTSanityTest.class); عودة جديدة testsuite (seleniumstsanitytest.class) ؛
} )

public static void main(String args[]) { ساكنة باطلة الرئيسية العامة (سلسلة args []) (
junit.textui.TestRunner.run(suite()); junit.textui.testrunner.run (جناح ()) ؛
} )
} )



Let me know if you have any comments / suggestions on how we can improve this tutorial. واسمحوا لي ان اعرف اذا كانت لديك أية تعليقات او اقتراحات حول كيفية تحسين هذا البرنامج التعليمي.