File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
main/java/ru/mystamps/web/feature/series/importing/extractor Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -309,11 +309,12 @@ protected String extractSellerUrl(Element body) {
309
309
}
310
310
311
311
protected String extractPrice (Element body ) {
312
- String price = getTextOfTheFirstElement (body , priceLocator );
313
- if (price == null ) {
312
+ Element elem = getFirstElement (body , priceLocator );
313
+ if (elem == null ) {
314
314
return null ;
315
315
}
316
316
317
+ String price = elem .ownText ();
317
318
LOG .debug ("Extracted price: '{}'" , price );
318
319
return price ;
319
320
}
Original file line number Diff line number Diff line change @@ -865,6 +865,23 @@ public void extractPriceShouldReturnTextOfPriceLocator() {
865
865
assertThat (msg , price , equalTo (expectedValue ));
866
866
}
867
867
868
+ @ Test
869
+ public void extractPriceShouldIgnoreTextOfChildrenTags () {
870
+ parser .setPriceLocator ("#price" );
871
+
872
+ String expectedValue = String .valueOf (Random .price ());
873
+ String html = String .format (
874
+ "<span id='price'>%s<span class='currency'>RUB</span</span>" ,
875
+ expectedValue
876
+ );
877
+ Element doc = createDocumentFromText (html );
878
+
879
+ String price = parser .extractPrice (doc );
880
+
881
+ String msg = String .format ("couldn't extract price from '%s'" , doc );
882
+ assertThat (msg , price , equalTo (expectedValue ));
883
+ }
884
+
868
885
//
869
886
// Tests for extractCurrency()
870
887
//
You can’t perform that action at this time.
0 commit comments