Code Duplication    Length = 21-22 lines in 6 locations

src/Oro/Bundle/ContactBundle/Tests/Selenium/Pages/Contact.php 4 locations

@@ 242-263 (lines=22) @@
239
        return $zipcode->attribute('value');
240
    }
241
242
    public function setAddressCountry($value, $addressId = 0)
243
    {
244
        $country = "//div[starts-with(@id,'s2id_oro_contact_form_addresses_{$addressId}_country')]/a";
245
        if ($this->isElementPresent("//div[@role='dialog']")) {
246
            $country = "//div[starts-with(@id,'s2id_oro_contact_address_form_country')]/a";
247
        }
248
        $country = $this->test->byXpath($country);
249
        $this->test->moveto($country);
250
251
        $country->click();
252
        $this->waitForAjax();
253
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
254
        $this->waitForAjax();
255
        $this->assertElementPresent(
256
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']",
257
            "Country's autocomplete doesn't return search value"
258
        );
259
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']")->click();
260
        $this->waitForAjax();
261
262
        return $this;
263
    }
264
265
    public function typeAddressCountry($value, $addressId = 0)
266
    {
@@ 265-286 (lines=22) @@
262
        return $this;
263
    }
264
265
    public function typeAddressCountry($value, $addressId = 0)
266
    {
267
        $country = "//div[starts-with(@id,'s2id_oro_contact_form_addresses_{$addressId}_country')]/a";
268
        if ($this->isElementPresent("//div[@role='dialog']")) {
269
            $country = "//div[starts-with(@id,'s2id_oro_contact_address_form_country')]/a";
270
        }
271
        $country = $this->test->byXpath($country);
272
        $this->test->moveto($country);
273
274
        $country->click();
275
        $this->waitForAjax();
276
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
277
        $this->waitForAjax();
278
        $this->assertElementPresent(
279
            "//div[@id='select2-drop']//div[contains(., '{$value}')]",
280
            "Country's autocomplete doesn't return search value"
281
        );
282
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$value}')]")->click();
283
        $this->waitForAjax();
284
285
        return $this;
286
    }
287
288
    public function getAddressCountry($addressId = 0)
289
    {
@@ 295-315 (lines=21) @@
292
            ->text();
293
    }
294
295
    public function setAddressRegion($region, $addressId = 0)
296
    {
297
        $xpath = "//div[starts-with(@id,'s2id_oro_contact_form_addresses_{$addressId}_region')]/a";
298
        if ($this->isElementPresent("//div[@role='dialog']")) {
299
            $xpath = "//div[starts-with(@id,'s2id_oro_contact_address_form_region')]/a";
300
        }
301
        $xpath = $this->test->byXpath($xpath);
302
        $this->test->moveto($xpath);
303
304
        $xpath->click();
305
        $this->waitForAjax();
306
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
307
        $this->waitForAjax();
308
        $this->assertElementPresent(
309
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']",
310
            "Country's autocopmlete doesn't return search value"
311
        );
312
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']")->click();
313
314
        return $this;
315
    }
316
317
    public function typeAddressRegion($region, $addressId = 0)
318
    {
@@ 317-337 (lines=21) @@
314
        return $this;
315
    }
316
317
    public function typeAddressRegion($region, $addressId = 0)
318
    {
319
        $xpath = "//div[starts-with(@id,'s2id_oro_contact_form_addresses_{$addressId}_region')]/a";
320
        if ($this->isElementPresent("//div[@role='dialog']")) {
321
            $xpath = "//div[starts-with(@id,'s2id_oro_contact_address_form_region')]/a";
322
        }
323
        $xpath = $this->test->byXpath($xpath);
324
        $this->test->moveto($xpath);
325
326
        $xpath->click();
327
        $this->waitForAjax();
328
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
329
        $this->waitForAjax();
330
        $this->assertElementPresent(
331
            "//div[@id='select2-drop']//div[contains(., '{$region}')]",
332
            "Country's autocopmlete doesn't return search value"
333
        );
334
        $this->test->byXpath("//div[@id='select2-drop']//div[contains(., '{$region}')]")->click();
335
336
        return $this;
337
    }
338
339
    public function getAddressRegion($addressId = 0)
340
    {

src/Oro/Bundle/SalesBundle/Tests/Selenium/Pages/Lead.php 2 locations

@@ 347-368 (lines=22) @@
344
        return $zipcode->attribute('value');
345
    }
346
347
    public function setAddressCountry($value, $addressId = 0)
348
    {
349
        $country = "//div[starts-with(@id,'s2id_oro_sales_lead_form_addresses_{$addressId}_country')]/a";
350
        if ($this->isElementPresent("//div[@role='dialog']")) {
351
            $country = "//div[starts-with(@id,'s2id_oro_sales_lead_address_form_country')]/a";
352
        }
353
        $country = $this->test->byXpath($country);
354
        $this->test->moveto($country);
355
356
        $country->click();
357
        $this->waitForAjax();
358
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($value);
359
        $this->waitForAjax();
360
        $this->assertElementPresent(
361
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']",
362
            "Country's autocomplete doesn't return search value"
363
        );
364
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$value}']")->click();
365
        $this->waitForAjax();
366
367
        return $this;
368
    }
369
370
    public function getAddressCountry($addressId = 0)
371
    {
@@ 377-397 (lines=21) @@
374
            ->text();
375
    }
376
377
    public function setAddressRegion($region, $addressId = 0)
378
    {
379
        $xpath = "//div[starts-with(@id,'s2id_oro_sales_lead_form_addresses_{$addressId}_region')]/a";
380
        if ($this->isElementPresent("//div[@role='dialog']")) {
381
            $xpath = "//div[starts-with(@id,'s2id_oro_sales_lead_address_form_region')]/a";
382
        }
383
        $xpath = $this->test->byXpath($xpath);
384
        $this->test->moveto($xpath);
385
386
        $xpath->click();
387
        $this->waitForAjax();
388
        $this->test->byXpath("//div[@id='select2-drop']/div/input")->value($region);
389
        $this->waitForAjax();
390
        $this->assertElementPresent(
391
            "//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']",
392
            "Country's autocopmlete doesn't return search value"
393
        );
394
        $this->test->byXpath("//div[@id='select2-drop']//div[normalize-space(.) = '{$region}']")->click();
395
396
        return $this;
397
    }
398
399
    public function getAddressRegion($addressId = 0)
400
    {