FAMILY = Father And Mother I Love You

Python标签

Pros and cons of end to end testing tools

My background in test automation is based on using Selenium WebDriver and Java. Since JavaScript has been widely used for testing web applications, I have decided to investigate tools currently available on the market. I will use these tools to make different scripts and hence find their advantages and disadvantages.

I have investigated the following tools and syntax for automation:

  1. Selenium Webdriver + Java
  2. Selenium WebDriver + Cucumber + Java
  3. Selenium WebDriver + Jasmine syntax for JavaScript applications
  4. Selenium WebDriver + Mocha syntax for JavaScript applications
  5. Cypress
  6. Selenium WebDriver + Protractor
  7. Selenium WebDriver + NightWatch
  8. Selenium WebDriver + WebDriverIO

Javascript Injection With Selenium, Puppeteer, And Marionette In Chrome And Firefox

Browser automation frameworks–like Puppeteer, Selenium, Marionette, and Nightmare.js–strive to provide rich APIs for configuring and interacting with web browsers. These generally work quite well, but you’re inevitably going to end up running into API limitations if you do a lot of testing or web scraping. You might find yourself wanting to conceal the fact that you’re using a headless browser, extract image resources from a web page, set the seed for Math.random(), or mock the browser’s geolocation before running your test suite. Your specific automation framework might provide a built-in way to accomplish some of these, but they all have their limitations.

如何突破网站对Selenium的屏蔽

使用selenium模拟浏览器进行数据抓取无疑是当下最通用的数据采集方案,它通吃各种数据加载方式,能够绕过客户JS加密,绕过爬虫检测,绕过签名机制。它的应用,使得许多网站的反采集策略形同虚设。由于selenium不会在HTTP请求数据中留下指纹,因此无法被网站直接识别和拦截。

timgjpg

这是不是就意味着selenium真的就无法被网站屏蔽了呢?非也。selenium在运行的时候会暴露出一些预定义的Javascript变量(特征字符串),例如"window.navigator.webdriver",在非selenium环境下其值为undefined,而在selenium环境下,其值为true(如下图所示为selenium驱动下Chrome控制台打印出的值)。

2018-09-09

在Java中调用Python

在微服务架构大行其道的今天,对于将程序进行嵌套调用的做法其实并不可取,甚至显得有些愚蠢。但有时候确实要面对这个问题,恰好我在项目中就遇到了这个问题,需要在Java程序中调用Python程序。关于在Java中调用Python程序的实现,根据不同的用途可以使用多种不同的方法,在这里就将在Java中调用Python程序的方式做一个总结。

方法一、直接通过Runtime进行调用,方法二、通过Jython调用。