, . , , . - ϲ, . , ...

, , , . , . , IT - php' , , .

, . HTML, CSS, , JS, Java SE. web- ...

, , , ' . , , , , ', .

. , ! , ... .

, . ³ . cars.com , , . , . ...

³ , pom.xml:


org.seleniumhq.selenium
selenium-server
2.25.0


javax.xml
jaxp-api
1.4.2


org.testng
testng
6.1.1
test

Selenium-server web- , jaxp-api xml-, testng , .

jax- ' , .

public class Hijacker {
private DocumentBuilderFactory docFactory = null;
private DocumentBuilder docBuilder = null;
private Document document = null;
private Element rootEl = null;
private TransformerFactory transformerFactory = null;
private Transformer transformer = null;
private DOMSource source = null;
public Hijacker () {

docFactory = DocumentBuilderFactory.newInstance ();
try {
docBuilder = docFactory.newDocumentBuilder ();
} Catch (ParserConfigurationException e) {
e.printStackTrace ();
}
document = docBuilder.newDocument ();
rootEl = document.createElement ("cars");
document.appendChild (rootEl);
transformerFactory = TransformerFactory.newInstance ();
try {
transformer = transformerFactory.newTransformer ();
} Catch (TransformerConfigurationException e) {
e.printStackTrace ();
}
}
public void addEntity (String makeVal, String modelVal) {
if (modelVal.equals ("All Models") | | makeVal.equals ("All Makes")) {
return;
} Else {
Element brandEl = document.createElement ("brand");
Attr make = document.createAttribute ("make");
make.setValue (makeVal);
brandEl.setAttributeNode (make);
rootEl.appendChild (brandEl);
Element model = document.createElement ("model");
model.setTextContent (modelVal);
brandEl.appendChild (model);
}
}
public void createReport () throws TransformerException {
source = new DOMSource (document);
StreamResult result = new StreamResult (new File ("E:   CarEntities.xml"));
transformer.transform (source, result);
}
}

xml-. . selenium testNG.

public class Parser {

Hijacker extractor = new Hijacker ();

@ Test
public void parseCars ()
throws InterruptedException, TransformerException {

WebDriver driver = new FirefoxDriver ();

driver.get ("");

WebElement makeEl = driver.findElement (By.id ("newMake"));
Select makeDropDown = new Select (makeEl);
List makeList = makeDropDown.getOptions ();

for (WebElement make: makeList) {

Thread.sleep (2000);

WebElement modelEl = driver.findElement (By.id ("newModel"));
Select modelDropDown = new Select (modelEl);

makeDropDown.selectByVisibleText (make.getText ());
List modelList = modelDropDown.getOptions ();

for (WebElement carModel: modelList) {
extractor.addEntity (make.getText (), carModel.getText ());
}

}

extractor.createReport ();

driver.close ();
}
}

, , . ' , , , , , WebDriver.

:

TSX


ZDX


DB9

: 17/12/12 @ 09:34
г

:

. 8 . ̳ .
25 , - Testers ' Talk # 09 : Post - apocalyptic testing
AMA :
" " ? .
Front - end Meet Up @ Lohika