Saltar al contenido
Underc0de /foro

Selenium: Automating the Browser with PHP-WebDriver by Facebook

🌐 This is an automatic translation of a topic from Underc0de, the largest Spanish-speaking hacking and IT community. Read the original (Spanish) and reply →
arthusu ·
What is Selenium?<br /><br />Selenium automates browsers. That's it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but it is certainly not limited to that. Boring web-based administration tasks can (and should) be automated as well.<br /><br />Selenium is supported by some of the largest browser vendors, who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in many other browser automation tools, APIs and frameworks.<br /><br />Which part of Selenium is right for me?<br /><br />Selenium Web Driver<br /><br />If you want to:<br />* Create robust, browser-based regression automation suites and tests<br />* Scale and distribute scripts across many environments<br /><br />Selenium IDE<br /><br />If you want to:<br />* Create quick bug reproduction scripts<br />* Create scripts to aid in automation-aided exploratory testing.<br /><br />Download Selenium<br /><br />You can go to the Selenium website, in the Download section: Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />You can choose whichever best suits your project, either Selenium IDE or Selenium Web Driver. In this mini-tutorial we will show something basic about both.<br /><br /><br />Selenium IDE<br /><br />If you only want one specific action, always the same action, I would recommend using Selenium IDE. It is available for Firefox and Chrome as an add-on; I will use the Firefox one in this case:<br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />In the following video we will see how, with Selenium, we go to my BLOG's page, then open a post, and then go back to the home page. This is something basic, since with Selenium we can enter data into a field and do many more things we would normally do manually with the browser.<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br /><br />You can also export your code to different targets and make execution faster.<br /><br />Selenium Web Driver<br /><br />What is the difference between Selenium IDE and Selenium Web Driver?<br /><br />The biggest difference is that with Selenium IDE we record things and play them back, but if you want something dynamic and interactive you need to use programming, and with Selenium Web Driver you can achieve that.<br /><br />The first thing we need to do is download the driver of our choice; it is available on the official Selenium page itself. In my case I will keep using Firefox:<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />You need to add the driver to your environment variables.<br /><br />I will also use the Selenium standalone server; in this case I will use version 3.8.1:<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />I will use the PHP driver created by Facebook:<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />The first thing to do is run my Selenium standalone server:<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />
Código: text
java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false
<br /><br />Finally, we can run our project from the console or from the web. I won't explain how to use the driver since Facebook has a great wiki here: Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br />Lastly, I'll tell you that with Selenium we have a powerful tool for task automation and we could do great things with it. An example:<br /><br />Los enlaces son solo para miembros. Registrate o iniciá sesión<br /><br /><br />That's all for this introduction, and I invite you to try Selenium in your automation projects.[/font]
B0xM4n ·
I'll be studying it, saving it for later
Grupo de WhatsApp