<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bakican Boydaş on Medium]]></title>
        <description><![CDATA[Stories by Bakican Boydaş on Medium]]></description>
        <link>https://medium.com/@bakicanboydas?source=rss-5cc41efcfa8c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*auen2f-B4UBABgNO</url>
            <title>Stories by Bakican Boydaş on Medium</title>
            <link>https://medium.com/@bakicanboydas?source=rss-5cc41efcfa8c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:22:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bakicanboydas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Firebase Metriklerin Microsoft Teams Alarmlarına Çevrilmesi (Firebase->Jira->Render->Teams…]]></title>
            <link>https://medium.com/turknettech/firebase-metriklerin-microsoft-teams-alarmlar%C4%B1na-%C3%A7evirilmesi-firebase-jira-render-teams-86f6ce8c8a3d?source=rss-5cc41efcfa8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/86f6ce8c8a3d</guid>
            <category><![CDATA[microsoft-teams]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[alerts]]></category>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Bakican Boydaş]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 10:43:45 GMT</pubDate>
            <atom:updated>2025-02-28T10:45:28.927Z</atom:updated>
            <content:encoded><![CDATA[<h3>Firebase Metriklerin Microsoft Teams Alarmlarına Çevrilmesi (Firebase-&gt;Jira-&gt;Render-&gt;Teams Notification)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgVoRh_O1e0D_mALSrL4JQ.png" /></figure><p>Mobil uygulamalarımızda her zaman kullanıcıların sorunsuz bir uygulama kullanmasını isteriz. Bu sebeple uygularımızı sıklıkla kontrol ederiz. Bu kontrolleri çeşitli yollarla yapabiliriz. Bu yollardan bir tanesi de Google Firebase ürününü kullanmaktan geçiyor. Firebase tarafında uygulamamızın kaç kişi tarafından kullanılıyor olduğunu, hangi sayfalarda hangi işlemleri gerçekleştirdiklerini ve uygulamada aldıkları sorunları takip edebiliyoruz. Bizi bu yazımızda ilgilendiren kısmı kullanıcıların uygulamada aldığı sorunları takip etmek ve bunları daha rahat takip edilebilir bir hale getirmektir. Biz bu yazımızda Firebase Alert sistemini Jira ile bağlayacağız Jira ile bağladığımız sistemi bir middleware yazılım yazarak Render üzerinden Teams ile birlikte notification göndermesini sağlayacağız.Normalde bu uyarılar mail üzerinden ilgili herkese otomatik olarak gönderiliyor fakat Teams kullanarak bunu grup chatinde paylaşabiliyoruz ve bu şekilde mail takibi yapmak yerine anlık olarak gruplar üzerinden ilgili herkes takibini yapıp anlık iletişim kurabiliyorlar. Her şeyin başladığı yer olan Firebase ile başlayalım.</p><h4>FIREBASE ALERT</h4><p>Firebase’de performans değerleri ve alınan sorunları takip edebilmek için çeşitli “uyarı”(alert) mekanizmaları kurabiliyoruz. Örnek olarak aşadağıdaki görselde bir “uyarı” kurmak istediğimizde bizden istenen değerleri ve aralıkları görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9zI002R7Y7rv_Z2i_O6r2g.png" /><figcaption>Firebase Alert ayarları</figcaption></figure><p>Biz burada bizden istenen değerleri vererek uyarı mekanizmamızı istediğimiz değerler içerisinde ayarlayabiliyoruz. Bu sayede ayarladığımız uyarı ilgili API için istenen değerleri aşarsa Firebase bize bir uyarı gönderiyor. Bu uyarıları göndermek için çeşitli yollar var. Bu çeşitli yollara örnek olarak aşağıdaki görseldeki örnekleri görebiliriz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nHzDjeXz-E6n6RQ4QJg8KA.png" /><figcaption>Firebase ile entegre olan platformlar</figcaption></figure><p>Burada Firebase’in bağlı olduğu veya bağlanabildiği çeşitli platformları görme şansımız var. Biz burada Jira kullanacağız. Normalde Google Cloud üzerinden Cloud Functions kullanarak Teams üzerine bir webhook ile birlikte mesaj gönderebiliriz fakat Cloud Functions yalnızca ödeme yapılan hesaplar üzerinden kullanılabiliyor. Biz de sadece Cloud Function kullanmak için ödeme yapmak istemiyoruz ve bunun daha uygun bir yolunu bulduk. Firebase bize oluşturulan uyarılar için Jira üzerinde task açabilmemizi sağlayan bir özellik sunuyor. Ve bunun en güzel yanı ücretsiz olması. Jira bağlantımızı Firebase ile birlikte tamamladıktan sonra Jira’da yapmamız geren adımları inceleyebiliriz.</p><h4>JIRA</h4><p>Jira bağlantımızı Firebase üzerinden tanımladıktan sonra bize Jira üzerinden oluşturulan bu taskların detaylarını gönderebileceğimiz bir weebhook gerekiyor. Bunu da Jira’nın webhook sistemi ile ayarlayabiliyoruz. Jira üzerinden webhook oluşturmak için sırasıyla aşağıdaki adımları takip etmemiz gerekiyor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*DRfTJhp8RWfAvcwvKqoS6w.jpeg" /><figcaption>Jira system tarafına gidilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*QpJpgn6wKM6BzCbGv61arg.jpeg" /><figcaption>Açılan menüde webhook seçilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LuiPFC2x6s0gDZcjwoISWw.jpeg" /><figcaption>Açılan webhook alanında create webhook tıklanır</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YMveCvfmqHouNmyYOLR4bQ.jpeg" /></figure><p>Son adımda webhook oluştururken önemli olan üç alanımız var. Bunlar webhookun gönderileceği URL, hangi eventler ile webhook çalıştırılacağı ve webhook ile birlikte hangi değerlerin gönderilebileceğidir. Burada bu ayarlamalarımızı yaptıktan sonra Jira tarafında şu an için yapacağımız bir şey kalmamış oluyor. Yazının ilerleyen taraflarında Jira’ya yine uğrayacağız fakat bu Jira API’leri ile alakalı olacak.</p><h4>Render</h4><p>Render yerine normalde DigitalOcean kullanabilirdim fakat Render en düşük hizmetini ücretsiz olarak sunuyor ve bu işimizi fazlasıyla görüyor. Bu sebeple Render kullanmayı tercih ettim. Render’da hizmeti öncelikle Web Service olarak oluşturacağız. Bunun için aşağıdaki resimleri takip edebilirsiniz,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbIRSGIPC3oDAX1q3WW6Kg.png" /><figcaption>Web Service seçilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*POR6y3-hJDvvEc-Q3LSPrw.png" /><figcaption>Sırasyla alanlar seçilir</figcaption></figure><p>Burada middleware kodlarımızın çalıştırılacağı repoyu seçiyoruz. Kodlarımızı yazının ilerleyen kısmında inceleyeceğiz şimdilik sadece githubda bir repo oluşturup Render ile birlikte bu repoyu bağlamanız yeterli. Bir isim veriyoruz ve projemizin dilini Docker olarak seçiyoruz çünkü projemizi Dockerize olarak kullanacağız. Branch ve bölgeyi de uygun olanları seçiyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EAsYJ9XLcrYZP49f3x4RTg.png" /><figcaption>Ücretsiz plan seçilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUzcSFCSsOR0uG_zv4owrw.png" /><figcaption>Advance ayarlardan Healthcheck açılır</figcaption></figure><p>Bu adımları tamamladıktan sonra Render deploy yapabiliriz. Render tarafındaki işimiz de şimdilik bitti. Kodlarımızı yazdıktan sonra Render tarafına tekrar geri döneceğiz. Şimdi sırada Teams üzerinden bir webhook oluşturma kaldı.</p><h4>Teams</h4><p>Teams üzerinde bir grup oluşturmamız gerekiyor. Bu grupta da çalışacak bir webhook oluşturmamız gerekiyor. Bunlar için sırasıyla aşağıdaki adımları takip edebiliriz,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*vJtLFYquAjSDjY7tfTIRzw.png" /><figcaption>Grubun ayar simgesine tıklanır</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*X23XiRMezplNQwrx8U4fkQ.png" /><figcaption>Workflows seçilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ah1U6MeiSM3AD36ECQXv1w.png" /></figure><p>Burada işimize yarayan workflow “Post to a chat when a webhook request is received” olan workflow seçilir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMD7eu7NaWn9zyfrggqoeQ.png" /><figcaption>İsim ve bağlantı kontrol edilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztP6Mlw99wvRRLvXN9Jquw.png" /><figcaption>Webhookun çalışacağı grup seçilir</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LayF4gXPp13ARu5HV98mIQ.png" /></figure><p>Teams tarafındaki işimiz tamamen bitti buraya bir daha uğramayacağız. Yalnızca oluşturulan linki bir yere kaydetmemiz gerekiyor. Teams grubumuza bu link üzerinden mesajlarımızı göndereceğiz. Şimdi artık middleware kodumuzu inceleyebiliriz.</p><h4>Middleware</h4><p>Python dilinin esnekliğini ve basitliğini kullanmak istedik. Bunu Dockerize yapacağız ve Render’da kolaylıkla çalışmasını sağlayacağız. Öncelikle kodumuzu inceleyelim. Her şeyi kodun içerisinde yorum satırı olarak yazacağım,</p><pre>from flask import Flask, request, jsonify<br>import requests<br><br>app = Flask(__name__)<br># BURAYA JIRADAN ALDIĞIN TOKENİ EKLE<br># Jirada API token nasıl yaratılır bu linkten kaynağı bulabilirsiniz &quot;https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/&quot;<br># Oluşturduğunuz tokeni burada kullanacağız<br>JIRA_TOKEN = &quot;YOUR-JIRA-TOKEN&quot;<br># Teams Webhook URL - Buraya kendi webhook URL&#39;ini ekle<br>TEAMS_WEBHOOK_URL = &quot;YOUR-TEAMS-WEBHOOK-URL&quot;<br><br># Bu fonksiyonun amacı Jira webhook gönderirken taskın tüm değerlerini alamıyoruz<br># Örnek olarak taskın başlığını alamıyoruz bu sebeple aşağıdaki fonksiyonla birlikte taskın başlığını alacağız<br># Burada url olarak kendi jira urlnizi kullanmanız gerekiyor &quot;turknet.atlassian.net&quot; kendi urliniz olmalı<br>def get_issue_summary(issue_key):<br>    url = f&quot;https://turknet.atlassian.net/rest/api/3/issue/{issue_key}?fields=summary&quot;<br>    # Burada header gönderirken Jira bizden aşağıdaki yapıyı kullanmamızı istiyor<br>    # Authorization headerı &quot;Basic&quot; ile başlamalı ve sonra Jira token vermemiz gerekiyor<br>    headers = {<br>        &quot;Accept&quot;: &quot;application/json&quot;,<br>        &quot;Authorization&quot;: &quot;Basic &quot; + JIRA_TOKEN  # JIRA API token&#39;ınızı buraya ekleyin<br>    }<br>    response = requests.get(url, headers=headers)<br>    if response.status_code == 200:<br>        return response.json().get(&quot;fields&quot;, {}).get(&quot;summary&quot;, &quot;Başlık bulunamadı&quot;)<br>    else:<br>        return &quot;Başlık alınamadı&quot;<br># Aşağıdaki fonksiyon ile taskın alertin ne zaman geldiğini yani taskın ne zaman oluşturulduğunun değerini alıyoruz   <br>def get_created_time(issue_key):<br>    url = f&quot;https://turknet.atlassian.net/rest/api/3/issue/{issue_key}?fields=created&quot;<br>    headers = {<br>        &quot;Accept&quot;: &quot;application/json&quot;,<br>        &quot;Authorization&quot;: &quot;Basic &quot; + JIRA_TOKEN  # JIRA API token&#39;ınızı buraya ekleyin<br>    }<br>    response = requests.get(url, headers=headers)<br>    if response.status_code == 200:<br>        return response.json().get(&quot;fields&quot;, {}).get(&quot;created&quot;, &quot;Zaman bulunamadı&quot;)<br>    else:<br>        return &quot;Zaman alınamadı&quot;<br># Burada taskın açıklamasını alıyoruz. Fakat alert bize gönderilirken taskın açıklaması içerisinde linkler mevcut.<br># Bu linkleri Teams üzerinden mesaj göndermek istediğimizde regex ile ayıklayıp daha okunaklı bir mesaj göndermek istiyoruz    <br>def get_issue_description(issue_key):<br>    #url = f&quot;https://turknet.atlassian.net/rest/api/3/issue/{issue_key}?fields=description&quot;<br>    url = f&quot;https://turknet.atlassian.net/rest/api/2/issue/{issue_key}?fields=description&quot;<br>    headers = {<br>        &quot;Accept&quot;: &quot;application/json&quot;,<br>        &quot;Authorization&quot;: &quot;Basic &quot; + JIRA_TOKEN<br>    }<br>    response = requests.get(url, headers=headers)<br>    if response.status_code == 200:<br>        description = response.json().get(&quot;fields&quot;, {}).get(&quot;description&quot;, &quot;Açıklama bulunamadı&quot;)<br>        # URL&#39;leri ve metinleri ayırmamızı yarayan regex kodunu aşağıda tanımlıyoruz<br>        import re<br>        pattern = r&#39;\[(.*?)\|(http[s]?://[^\s]+)\]&#39;<br>        matches = re.findall(pattern, description)<br>        for text, url in matches:<br>            # Tıklanabilir URL formatı, ayırdığımız urli tıklanabilir yapmak için aşağıdaki kodu kullanıyoruz<br>            description = description.replace(f&quot;[{text}|{url}]&quot;, f&quot;[{text}]({url})&quot;)<br>        return description<br>    else:<br>        return &quot;Açıklama alınamadı&quot;<br><br># Burada &quot;/jira-webhook&quot; adında bir endpoint oluşturuyoruz.<br># Yazımızın Jira kısmında webhook oluştururken bir url çalıştırmak istediğimizden bahsetmiştik.<br># Renderda oluşturduğumuz web servisin endpointi olarak Jirada bunu tanımlıyoruz.<br># Ve bu endpointe bir POST isteği alıyoruz.<br>@app.route(&quot;/jira-webhook&quot;, methods=[&quot;POST&quot;])<br>def jira_webhook():<br>    data = request.json  # Jira&#39;dan gelen JSON verisi<br>    <br>    if not data or &quot;issue&quot; not in data:<br>        return jsonify({&quot;message&quot;: &quot;Geçersiz veri&quot;})<br>    <br>    # Jiranın bize direkt olarak gönderdiği verilerden biri &quot;issue&quot; verisi ve &quot;issue_key&quot; verisi<br>    # Bu verileri kolaylıkla aşağıdaki şekilde alabiliyoruz fakat diğer verileri yukarıda tanımladığımız fonksiyonlar ile alabiliyoruz<br>    issue = data[&quot;issue&quot;]<br>    issue_key = issue[&quot;key&quot;]<br>    issue_summary = get_issue_summary(issue_key)<br>    issue_time = get_created_time(issue_key)<br>    issue_description = get_issue_description(issue_key)<br>   <br><br>    # Teams için Adaptive Card mesaj formatı<br>    # Teams yalnızca belirli formatlarda mesajları kabul ediyor. Aşağıdaki mesaj tipi Teams&#39;in kabul ettiği formatlardan bir tanesi<br>    # Burada gönderdiğimiz mesajın nasıl göründüğünü aşağıda ekleyeceğim screenshot ile görebilirsiniz<br>    teams_message = {<br>        &quot;type&quot;: &quot;message&quot;,<br>        &quot;attachments&quot;: [<br>            {<br>                &quot;contentType&quot;: &quot;application/vnd.microsoft.card.adaptive&quot;,<br>                &quot;content&quot;: {<br>                    &quot;$schema&quot;: &quot;http://adaptivecards.io/schemas/adaptive-card.json&quot;,<br>                    &quot;type&quot;: &quot;AdaptiveCard&quot;,<br>                    &quot;version&quot;: &quot;1.4&quot;,<br>                    &quot;body&quot;: [<br>                        {<br>                            &quot;type&quot;: &quot;TextBlock&quot;,<br>                            &quot;text&quot;: &quot;⚠️ FİREBASE YENİ UYARI ⚠️&quot;,<br>                            &quot;size&quot;: &quot;Large&quot;,<br>                            &quot;weight&quot;: &quot;Bolder&quot;<br>                        },<br>                        {<br>                            &quot;type&quot;: &quot;FactSet&quot;,<br>                            &quot;facts&quot;: [<br>                                {<br>                                    &quot;title&quot;: &quot;Task Numarası:&quot;,<br>                                    &quot;value&quot;: issue_key<br>                                },<br>                                {<br>                                    &quot;title&quot;: &quot;Başlık:&quot;,<br>                                    &quot;value&quot;: issue_summary<br>                                },<br>                                {<br>                                    &quot;title&quot;: &quot;Oluşturulma Zamanı:&quot;,<br>                                    &quot;value&quot;: issue_time<br>                                },<br>                                {<br>                                    &quot;title&quot;: &quot;Açıklama:&quot;,<br>                                    &quot;value&quot;: issue_description<br>                                },<br>                                {<br>                                    &quot;title&quot;: &quot;Detaylar:&quot;,<br>                                    &quot;value&quot;: f&quot;[Jira&#39;da Görüntüle](https://turknet.atlassian.net/browse/{issue_key})&quot;<br>                                }<br>                            ]<br>                        }<br>                    ]<br>                }<br>            }<br>        ]<br>    }<br><br>    # Teams Webhook&#39;a POST isteği gönder<br>    response = requests.post(TEAMS_WEBHOOK_URL, json=teams_message)<br>    <br>    if response.status_code == 200:<br>        return jsonify({&quot;message&quot;: &quot;Teams&#39;e gönderildi&quot;})<br>    else:<br>        return jsonify({&quot;message&quot;: &quot;Teams&#39;e gönderilemedi&quot;, &quot;error&quot;: response.text})<br># Burada da Render içerisinde çalıştırdığımız web servisin sürekli çalışıp çalışmadığının kontrolü sağlanıyor.<br># Burada bir &quot;/health&quot; endpointi oluşturduk. Ve sürekli olarak eğer ulaşılabiliyorsa 200 status code gönderiyoruz<br># Yazının üst taraflarında Render anlattığımız kısımda Advance ayarlarında bu endpointi healthchek için tanımladığımızdan bahsetmiştik.<br>@app.route(&#39;/health&#39;, methods=[&#39;GET&#39;])<br>def health_check():<br>    return jsonify({&quot;status&quot;: &quot;ok&quot;}), 200<br><br># Burada da Render üzerinde çalıştıracağımız ip ve portları tanımlıyoruz. Bu localhost içerisinde çalıştırmayı sağlıyor.<br>if __name__ == &quot;__main__&quot;:<br>    app.run(host=&quot;0.0.0.0&quot;, port=8080)</pre><p>Yukarıdaki kodun çıktısı olarak aşağıdaki screenshot sonucumuzu gösterecektir.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lG4LuLKG8rRgUeisiKcYqw.png" /></figure><p>Bu kodumuzu Docker olarak Render da çalıştırmıştık şimdi dockerize yapmak için gerekli kodlarımızı da hazırlayalım. Burada python kodumuz ile birlikte iki dosyamız daha olacak. Biri gerekli kütüphanelerin yüklenmesini sağlamak için Docker kodu diğeri de gerekli kütüphanelerin tanımlamasını sağlamak için requirement dosyası.</p><pre># Çalıştırmak istediğimiz python image tanımlanıyor<br>FROM python:3.11-slim<br><br># Çalıştırılmak istenen directory tanımlanıyor<br>WORKDIR /app<br><br># Requiremen kopyalanıyor<br>COPY requirements.txt .<br><br># Requirement içerisinde bulunan gerekli kütüphaneler yükleniyor<br>RUN pip install --no-cache-dir -r requirements.txt<br><br># Kodun hepsi kopyalanıyor<br>COPY . .<br><br># Çalıştırılmak istenen port expose ediliyor<br>EXPOSE 8080<br><br># Uygulama çalışyırılıyor.<br>CMD [&quot;python&quot;, &quot;firebase_alert.py&quot;]</pre><p>Bu dosyanın adını Dockerfile olarak tanımlıyoruz.</p><pre>flask<br>requests</pre><p>Bu da requirement.txt dosyasımızın içeriği. Yalnızca iki tane kütüphane kullandığımız için bunları belirtiyoruz. Evet sonunda kodlarımız hazır bunları Render içerisinde tanımladığımız repoya kaydediyoruz. Commitlerimizi yaptıktan sora tekrar Render’a dönüyoruz ve son commitlerimizi deploy yapıyoruz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h3bvNaWtDaod3NhB464UCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyUJ3SnkC7RCLR0ZLSoRWg.png" /></figure><p>Ve kodumuz deploy olduktan sonra artık Firebase üzerinde oluşturulan her alert Jira üzerinde bir task oluşturuyor. Oluşturulan bu tasklar yazmış olduğumuz middleware ile birlikte Teams grubumuza mesaj olarak gönderiliyor.</p><h4>Sonuç</h4><p>Buna benzer işlemleri yazımızın başında da belirttiğimiz gibi Google Cloud kullanarak da yapabilirdik. Veya DigitalOcean üzerinden servisimizi çalıştırabilirdik. Fakat bu işlemleri yapmamazın sebebi sıfır maliyet ile çalışmaktı. Yazımızda sıfır maliyet ile Teams üzerinden takip edilebilir bir sistemin gerçekleştirilmesini inceledik. Yazımı bana mükemmel bir mentor ve abi olarak yol gösterdiği için <a href="https://medium.com/u/3b680e349c68">CaglarU</a> ‘ya teşekkür ederek bitirmek istiyorum. Onun yol göstermesi sayesinde bunları beraber başarabildik.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86f6ce8c8a3d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/turknettech/firebase-metriklerin-microsoft-teams-alarmlar%C4%B1na-%C3%A7evirilmesi-firebase-jira-render-teams-86f6ce8c8a3d">Firebase Metriklerin Microsoft Teams Alarmlarına Çevrilmesi (Firebase-&gt;Jira-&gt;Render-&gt;Teams…</a> was originally published in <a href="https://medium.com/turknettech">Turknet Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ayrılmış Repolarla Mobil Otomasyon]]></title>
            <link>https://medium.com/turknettech/ayr%C4%B1lm%C4%B1%C5%9F-repolarla-mobil-otomasyon-7bb704a7acc0?source=rss-5cc41efcfa8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bb704a7acc0</guid>
            <category><![CDATA[test]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testng]]></category>
            <dc:creator><![CDATA[Bakican Boydaş]]></dc:creator>
            <pubDate>Thu, 30 Nov 2023 14:29:00 GMT</pubDate>
            <atom:updated>2023-12-08T11:51:44.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*My4MoxNPP9VV8fRKEjTp2g.png" /></figure><p>Merhaba, farklı ortamlarda farklı otomasyonlar koşmak istediğimizde bunların yönetimi zorlaşabiliyor. Özellikle elementlerde değişen farklılıklar bizi bu konuda zorlayabiliyorlar. Bununla birlikte farklı ortamlarda farklı fonksiyon gereksinimleri de tek bir proje içerisinde çalıştırmayı zorlaştıran sebepler arasında. Bu sebeple farklı işletim sistemleri için çalıştıracağımız test otomasyonlarını farklı repolarda tutarsak repoları kontrol etmemiz daha kolay ve daha düzenli olur. Daha önceki yazımda mobil test otomasyon projesi nasıl oluşturulur, proje için neler gereklidir ve kurulumları nasıl yapılır bunu anlatmıştım. Bu yazıyı <a href="https://medium.com/@bakicanboydas/java-testng-appium-and-more-e343365e5bc2">bu linki</a> takip ederek okuyabilirsiniz.</p><p>Şimdi bu yazıda anlatmak istediğim konu iOS ve Android cihazların otomasyonları farklı repolarda nasıl koşulur ve repolar nasıl ayrılır bunu anlatmak olacak.</p><h3><strong>Repoları Ayırmak ve Yönetmek</strong></h3><p>Normalde otomasyon projelerimiz tek bir repodan oluşuyor tek repodan oluşan bu projelerimizde classlarımızı istediğimiz gibi kullanıp yönetebiliyoruz. Fakat hem iOS hem de Android test caselerimizi, objelerimizi, elementlerimizi yönetmemiz çok kolay olmuyor. Bunların yönetimini daha kolay bir duruma getirmek için repoları ayırmayı tercih ediyoruz. Fakat elimizde 2 repo olmayacak 3 repo olacak. 3. repo nereden çıktı diye kendi kendinize sorarken cevaplayayım, bizim kullandığımız Base Test, Base Page ve utils dosyalarımızı Android ve iOS projeler için ortak kullanacağız. Bu taraflarda yapılacak değişiklikleri her iki proje için ayrı ayrı yapmak hem iş yükü açısından hem de karışıklık açısından işimizi kolaylaştırmayacak. Bu sebeple 3. bir main-framework yapımız olacak. Bu yapı içerisinde yukarıda bahsettiğim ortak kullanılan classlar ve kullanılabilecek classlar yazılacak. Yani özetlemek gerekirse Android için bir repo, iOS için bir repo ve main-framework için ayrı bir repo olmak üzere 3 repomuz olacak.</p><p><strong>Repolar Nasıl Ayrılır?</strong></p><p>Şimdi öncelikle ortak kullanacağımız classlar ve dosyaları belirleyip bunları src/main içerisinde eklememiz gerekiyor. Bu yapı basitçe şu şekilde olmalı;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*eslHtbLyuHeWd9EsKUdWzg.png" /><figcaption>Main Framework basit yapısı</figcaption></figure><p>Burada şunu sorduğunuzu duyar gibiyim, bunları src/test klasörü altında kullanıyorduk neden main klasörüne taşıdık. Şimdi Android ve iOS repolarımızda bu classlar olmayacağı için bunlara erişimlerini sağlamamız gerekiyor. Bunun yöntemi de bu main-framework için bir artifact oluşturup bu artifactı Android ve iOS projelerinde pom içerisinde dependency olarak kullanmamız gerekiyor. Bu sayede Android ve iOS projelerimiz bu classlara ulaşabiliyorlar. Burada main taşımamızın sebebi de bu artifactın oluşturulması test klasörü altında yapılamıyor main içerisinde yapılabiliyor. Bir diğer dikkat etmemiz konu TestNG problemi. TestNG dependency eklenirken scope genellikle test olarak belirtiliyor. Bu test klasörünün derlenmesini sağlayan bir yöntem. Ve TestNG bu şekilde kullanılırsa main klasörüne erişemiyor. Bunun için yapmamız gereken şey scope için compile olarak değişiklik yapmak veya scope ibaresini tamamen silmektir. Sildiğimiz zaman TestNG default olarak compile scope kullanır. Bu kısmı da halletiğimize göre main framework yapımızda pom.xml dosyamızın kodları nasıl olmalı birlikte bakalım.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;<br>         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;<br>    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br><br>    &lt;groupId&gt;org.turknet.mobile&lt;/groupId&gt;<br>    &lt;artifactId&gt;turknetMobileFramework&lt;/artifactId&gt;<br>    &lt;version&gt;${mobile-framework.version}&lt;/version&gt;<br><br>    &lt;properties&gt;<br>        &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;<br>        &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;<br>        &lt;mobile-framework.version&gt;1.0&lt;/mobile-framework.version&gt;<br>    &lt;/properties&gt;<br><br><br>    &lt;dependencies&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;io.appium&lt;/groupId&gt;<br>            &lt;artifactId&gt;java-client&lt;/artifactId&gt;<br>            &lt;version&gt;7.6.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.testng&lt;/groupId&gt;<br>            &lt;artifactId&gt;testng&lt;/artifactId&gt;<br>            &lt;version&gt;7.7.1&lt;/version&gt;<br>            &lt;scope&gt;compile&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;<br>            &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;<br>            &lt;version&gt;3.141.59&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;com.aventstack&lt;/groupId&gt;<br>            &lt;artifactId&gt;extentreports&lt;/artifactId&gt;<br>            &lt;version&gt;5.1.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>            &lt;scope&gt;compile&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>            &lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>            &lt;version&gt;1.18.26&lt;/version&gt;<br>            &lt;scope&gt;provided&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;io.qameta.allure&lt;/groupId&gt;<br>            &lt;artifactId&gt;allure-testng&lt;/artifactId&gt;<br>            &lt;version&gt;2.18.1&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>    &lt;/dependencies&gt;<br><br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;3.1&lt;/version&gt;<br>                &lt;configuration&gt;<br>                    &lt;source&gt;11&lt;/source&gt; &lt;!--For JAVA 8 use 1.8--&gt;<br>                    &lt;target&gt;11&lt;/target&gt; &lt;!--For JAVA 8 use 1.8--&gt;<br>                &lt;/configuration&gt;<br>            &lt;/plugin&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;3.0.0-M5&lt;/version&gt;<br>                &lt;configuration&gt;<br>                    &lt;suiteXmlFiles&gt;<br>                        &lt;suiteXmlFile&gt;testng.xml&lt;/suiteXmlFile&gt;<br>                    &lt;/suiteXmlFiles&gt;<br>                    &lt;argLine&gt;<br>                        -javaagent:&quot;${settings.localRepository}/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar&quot;<br>                    &lt;/argLine&gt;<br>                &lt;/configuration&gt;<br>                &lt;dependencies&gt;<br>                    &lt;dependency&gt;<br>                        &lt;groupId&gt;org.aspectj&lt;/groupId&gt;<br>                        &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;<br>                        &lt;version&gt;1.9.6&lt;/version&gt;<br>                    &lt;/dependency&gt;<br>                &lt;/dependencies&gt;<br>            &lt;/plugin&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-deploy-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;2.8.1&lt;/version&gt;<br>                &lt;executions&gt;<br>                    &lt;execution&gt;<br>                        &lt;id&gt;default-deploy&lt;/id&gt;<br>                        &lt;phase&gt;deploy&lt;/phase&gt;<br>                        &lt;goals&gt;<br>                            &lt;goal&gt;deploy&lt;/goal&gt;<br>                        &lt;/goals&gt;<br>                    &lt;/execution&gt;<br>                &lt;/executions&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br>    &lt;distributionManagement&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;tn-maven&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/tn-maven/&lt;/url&gt;<br>        &lt;/repository&gt;<br>    &lt;/distributionManagement&gt;<br>    &lt;repositories&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;turknet-test&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/maven-public/&lt;/url&gt;<br>            &lt;releases&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/releases&gt;<br>            &lt;snapshots&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/snapshots&gt;<br>        &lt;/repository&gt;<br>    &lt;/repositories&gt;<br>&lt;/project&gt;</pre><p>Peki nasıl oluşturulacak bu artifact. Artifact oluşturmak için 2 yöntem var. Benim önerdiğim basit yöntem maven ile oluşturulması. Bir diğer yöntem de Intellij IDE ile oluşturulması. Maven ile oluşturulma kısmında yapacağımız sadece iki işlem var. <strong>mvn clean</strong> ve <strong>mvn install</strong> komutlarıyla artifactımızı direkt olarak target klasörünün içine oluşturabiliyoruz. Gerçekten çok basit bir yöntem. Bu oluşturduğumuz artifactın sistem pathini daha sonrasında Android ve iOS projelerimizin pom.xml dosyalarında dependency olarak ekliyoruz ve bu projelerimizde main-framework classlarımızı ve fonksiyonlarımızı kullanabiliyoruz. Bu local çalıştırılacak sistemlerde kullanılması optimal olan bir yöntem. Peki takım arkadaşlarımızla çalışacağımız zaman bu yöntem ne kadar sağlıklı olabilir? Ben main-framework içerisinde her değişiklik yaptığımda oluşturuduğum artifactı takım arkadaşıma mı göndermem gerekecek? Bu çok zor bir işlem ve gereksiz bir işlem. Bunun yerine DevOps arkadaşlardan destek alarak Nexus içerisinde otomatik olarak artifact oluşturacak bir pipeline sistemi oluşturduk. Main-framework içerisinde bir değişiklik yapıldığı zaman otomatik olarak Nexus yeni bir artifact oluşturup bunun linkini bize veriyor. Bu sayede sadece bu linki Android ve iOS projelerimizin pom.xml dosyalarında dependency olarak eklediğimizde main-frameworke erişebiliyoruz. Ve takımdaki herkes bağımsız bir şekilde otomasyon üstünde çalışmalarına devam edebiliyorlar. Tek yapmaları gereken artifactın oluşturulan versiyonunu değiştirmeleri. Hemen bakalım bu dependency yapısı nasıl oluyormuş;</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;<br>         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br>         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;<br>    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br><br>    &lt;groupId&gt;org.example&lt;/groupId&gt;<br>    &lt;artifactId&gt;turknetMobile&lt;/artifactId&gt;<br>    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;<br><br>    &lt;properties&gt;<br>        &lt;maven.compiler.source&gt;11&lt;/maven.compiler.source&gt;<br>        &lt;maven.compiler.target&gt;11&lt;/maven.compiler.target&gt;<br>    &lt;/properties&gt;<br><br><br>    &lt;dependencies&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;io.appium&lt;/groupId&gt;<br>            &lt;artifactId&gt;java-client&lt;/artifactId&gt;<br>            &lt;version&gt;7.6.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.testng&lt;/groupId&gt;<br>            &lt;artifactId&gt;testng&lt;/artifactId&gt;<br>            &lt;version&gt;7.6.0&lt;/version&gt;<br>            &lt;!--  &lt;scope&gt;test&lt;/scope&gt;--&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;<br>            &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;<br>            &lt;version&gt;3.141.59&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;com.aventstack&lt;/groupId&gt;<br>            &lt;artifactId&gt;extentreports&lt;/artifactId&gt;<br>            &lt;version&gt;5.1.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>            &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>            &lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>            &lt;version&gt;1.18.26&lt;/version&gt;<br>            &lt;scope&gt;provided&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;io.qameta.allure&lt;/groupId&gt;<br>            &lt;artifactId&gt;allure-testng&lt;/artifactId&gt;<br>            &lt;version&gt;2.18.1&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br><br>        &lt;!--  &lt;dependency&gt;<br>              &lt;groupId&gt;org.turknet.mobile&lt;/groupId&gt;<br>              &lt;artifactId&gt;turknetMobileFramework&lt;/artifactId&gt;<br>              &lt;version&gt;1.0&lt;/version&gt;<br>              &lt;scope&gt;system&lt;/scope&gt;<br>              &lt;systemPath&gt;/Users/bakican.boydas/Documents/projects/mobile-automation-android/target/turknetMobileFramework-1.0.jar&lt;/systemPath&gt;<br>          &lt;/dependency&gt;--&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.turknet.mobile&lt;/groupId&gt;<br>            &lt;artifactId&gt;turknetMobileFramework&lt;/artifactId&gt;<br>            &lt;version&gt;1.0.main.48&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br><br>    &lt;/dependencies&gt;<br><br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;3.1&lt;/version&gt;<br>                &lt;configuration&gt;<br>                    &lt;source&gt;11&lt;/source&gt; &lt;!--For JAVA 8 use 1.8--&gt;<br>                    &lt;target&gt;11&lt;/target&gt; &lt;!--For JAVA 8 use 1.8--&gt;<br>                &lt;/configuration&gt;<br>            &lt;/plugin&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;<br>                &lt;version&gt;3.0.0-M5&lt;/version&gt;<br>                &lt;configuration&gt;<br>                    &lt;suiteXmlFiles&gt;<br>                        &lt;suiteXmlFile&gt;testngSuites/testng.xml&lt;/suiteXmlFile&gt;<br>                    &lt;/suiteXmlFiles&gt;<br>                    &lt;argLine&gt;<br>                        -javaagent:&quot;${settings.localRepository}/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar&quot;<br>                    &lt;/argLine&gt;<br>                &lt;/configuration&gt;<br>                &lt;dependencies&gt;<br>                    &lt;dependency&gt;<br>                        &lt;groupId&gt;org.aspectj&lt;/groupId&gt;<br>                        &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;<br>                        &lt;version&gt;1.9.6&lt;/version&gt;<br>                    &lt;/dependency&gt;<br>                &lt;/dependencies&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br><br>    &lt;distributionManagement&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;turknet-test&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/tn-maven/&lt;/url&gt;<br>        &lt;/repository&gt;<br><br>    &lt;/distributionManagement&gt;<br>    &lt;repositories&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;turknet-test&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/tn-maven/&lt;/url&gt;<br>            &lt;releases&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/releases&gt;<br>            &lt;snapshots&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/snapshots&gt;<br>        &lt;/repository&gt;<br>    &lt;/repositories&gt;<br><br>&lt;/project&gt;</pre><p>Yukarıdaki kodda da göreğiniz üzere yorum satırları içerisinde bir bölüm mevcut. Bu bölüm local olarak çalışırken kullandığım ve oluşturulan artifact ile jar dosyasının pathini dependency olarak verdiğim bir bölüm. Bu bölüme remote olarak çalışırken ihtiyacım yok çünkü Nexus ile birlikte kullandığım dependency bu kod parçası;</p><pre>&lt;dependency&gt;<br>            &lt;groupId&gt;org.turknet.mobile&lt;/groupId&gt;<br>            &lt;artifactId&gt;turknetMobileFramework&lt;/artifactId&gt;<br>            &lt;version&gt;1.0.main.48&lt;/version&gt;<br>        &lt;/dependency&gt;</pre><p>Ve bununla birlikte bu kısmı da kullanmamız gerekiyor bu kısımda dependency olarak kullanılacak versiyonu nereden çekeceğimizi belirtiyoruz;</p><pre><br>&lt;distributionManagement&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;turknet-test&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/tn-maven/&lt;/url&gt;<br>        &lt;/repository&gt;<br><br>    &lt;/distributionManagement&gt;<br>    &lt;repositories&gt;<br>        &lt;repository&gt;<br>            &lt;id&gt;turknet-test&lt;/id&gt;<br>            &lt;url&gt;https://artifact.turknet.net.tr/repository/tn-maven/&lt;/url&gt;<br>            &lt;releases&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/releases&gt;<br>            &lt;snapshots&gt;<br>                &lt;enabled&gt;true&lt;/enabled&gt;<br>            &lt;/snapshots&gt;<br>        &lt;/repository&gt;<br>    &lt;/repositories&gt;</pre><p>Sonuç olarak farklı repolar ile nasıl bağlantı sağlandığını görmüş olduk.</p><p><strong>Android ve iOS Proje Yapısı</strong></p><p>Burada 2 proje için genel yapı tamamen aynı. Class isimlendirmeleri ve yazılan test caseler tamamen aynı. Burada tek değişen şey testng.xml dosyalarında parametre olarak gönderdiğimiz değerler ve pageObjectlerin içerisinde yazılan elementler. Genel yapımızın nasıl olacağını resimde görebilirsiniz;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*_dUfLbE_Q-DNVkZYmyEc3w.png" /><figcaption>Android ve iOS genel yapısı</figcaption></figure><p>Burada constant yapısını kullanmamızın sebebi artık BaseTest ve properties dosyalarını repoları ayırdığımız için birlikte kullanamamız. Normalde properties dosyalarımızı BaseTest içerisinde tanımladıktan sonra test classlarımız içerisinde gerekli yerlerde kullanıyorduk. Şimdi 2 proje için de constants yapısını kullanarak bu bağımlılıktan kurtulmuş olduk. Bununla birlikte Android için elementleri locate ederken id ve xpath kullanabilirken iOS için yalnızca xpath kullanabiliyoruz. Bu biraz iOS’un kendi yapısından kaynaklanan bir durum. Bunlar haricinde yapımız tamamen aynı. Kullandığımız ortak fonksiyonları yine BasePage tarafından kullanıyoruz farklılık gördüğümüz noktalarda ise farklılıkları pageObjectler içerisinde değiştiriyoruz. Örnek vermek gerekirse Android deviceBack yani cihazın geri tuşu fonksiyonunu kullanabilirken iOS’ta böyle bir durum mevcut değil iOS tarafında uygulama içerisindeki geri tuşunu kullanıyoruz. Bu tarz ufak farklılıklar testi yazarken karşınıza çıkacaktır. Öncesinde bunlar için yapmanız gereken bir işlem yok.</p><p><strong>Kapanış</strong></p><p>Bu yazıda amacımız var olan otomasyon projemiz için farklı repolara ayırıp nasıl kullanabiliriz bunu anlatmaktı. Bu yazıyı ve projeyi birlikte hazırladığımız <a href="https://medium.com/u/1b6400110b58">Ayşenur Çelik</a> arkadaşıma da teşekkür ederek yazıyı tamamlıyorum. Okuduğunuz için teşekkür ederiz.</p><p><strong>İlk projenin linki</strong></p><p><a href="https://medium.com/@bakicanboydas/java-testng-appium-and-more-e343365e5bc2">https://medium.com/@bakicanboydas/java-testng-appium-and-more-e343365e5bc2</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bb704a7acc0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/turknettech/ayr%C4%B1lm%C4%B1%C5%9F-repolarla-mobil-otomasyon-7bb704a7acc0">Ayrılmış Repolarla Mobil Otomasyon</a> was originally published in <a href="https://medium.com/turknettech">Turknet Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java, TestNG, Appium and More]]></title>
            <link>https://medium.com/@bakicanboydas/java-testng-appium-and-more-e343365e5bc2?source=rss-5cc41efcfa8c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e343365e5bc2</guid>
            <category><![CDATA[pom]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[appium]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[testng]]></category>
            <dc:creator><![CDATA[Bakican Boydaş]]></dc:creator>
            <pubDate>Sat, 16 Sep 2023 22:05:20 GMT</pubDate>
            <atom:updated>2023-09-16T22:05:20.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Photo was created from Dall-E" src="https://cdn-images-1.medium.com/max/1024/1*xj3Uk2oENZ_PfRQcAXIfQg.jpeg" /></figure><p>Hello, there are many automation documents and courses on the internet. I can say that this article will not be much different from these. However, BDD is generally used in these automation trainings. I will not use something like this for this article. I will show you how to create a framework from scratch using the POM design pattern. There are certain technologies we need here. I will mention these in the next heading. I hope this article will be a nice and understandable article for those who want to start automation or see something different.</p><h3>Requirements</h3><ol><li>Some Java knowledge</li><li>Appium <a href="https://github.com/appium/appium-desktop/releases">(Download link is here)</a></li><li>An Android device</li><li>IntelliJ <a href="https://www.jetbrains.com/idea/download/?section=windows">(Download link is here)</a></li><li>SDK tools <a href="https://developer.android.com/tools/releases/platform-tools">(Download link is here)</a></li><li>Maven <a href="https://maven.apache.org/download.cgi">(Download link is here)</a></li><li>And Java <a href="https://www.oracle.com/tr/java/technologies/downloads/">(Download link is here)</a></li></ol><h3>Here we go</h3><p>After making all the installations, we need to define the computer PATH. First of all, we save the file locations where the Java, Maven and SDK files are installed in the environment variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*1hZIEoMoWmR2k871qqTXFw.png" /></figure><p>Afterwards, we save these additions in Path within the system variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*v3SwClYf6B7zeOJ6ZjGKLw.png" /></figure><p>After making our additions, we are done with this side by clicking OK and save. Now we need to check if our additions are working correctly. For this, we open the command system and check the versions respectively as shown in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lhM3CizTbO7a7BhVITQ-Q.png" /></figure><p>If we can see the versions correctly after adding all the environment variables, there is no problem.</p><p>Now let’s open IntelliJ and create our first POM design pattern here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*ufAR7XgQ4GdM-JxTWMFrMg.png" /></figure><p>The things we need to pay attention to when creating a project with IntelliJ are that the language we will use in the project must be Java and the building system must be selected Maven. I am using Java version 11 in this project, you can use this version or a different version if you wish. It is worth mentioning that if the version is different, some code pieces may need to be written differently. After our project is opened, let’s start creating our POM pattern.</p><h3>POM Design Pattern</h3><blockquote>The POM (Page Object Model) is a design pattern used in software testing and test automation to enhance the maintainability and reusability of test scripts and improve the overall efficiency of test automation efforts, especially in web applications. It is not specific to a particular programming language or testing framework but is a concept that can be applied in various testing environments.</blockquote><p>This definition above is a definition created by Chat GPT. And itexplained very well what the POM design pattern means in short. In our project, I will show the file directories required for this structure in the picture below, and I think you will not have any difficulties in the rest of the article if you use this file arrangement and naming in your project.</p><p>We delete the Main directory from our project because we have no business with this part. The simpler the directories look, the easier it is to track projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*EjfWDhSNT1e5iO_gnwwirw.png" /></figure><p>Now here we have a home directory under the src directory. This is the test directory. We have 2 different directories under the test directory. These are java and resources directories. There are 3 different packages under the java directory: “base”, “Framework”, “utils” respectively. There are 3 different properties files under the resources directory: “config.properties”, “extent.properties”, “log4j2.properties” respectively. I will explain what these properties files do later. Before these, let’s create the packages under the “Framework” and “utils” packages, respectively. While there are “pageObjects” and “pageTests” packages under the Framework package, there are “extentReports”, “listeners” and “logs” packages under the “utils” package. And finally we have the testngSuites directory located in the same location as the src directory. And we have the pom.xml file, which is automatically created when the project is created. I know it may seem complicated for someone encountering such a system for the first time, but I hope it will all be understandable for you at the end of the article.</p><p>Now, first of all, we need to specify the technologies we want to use and which versions we want to use in pom.xml.</p><h3>pom.xml</h3><p>The pom.xml file is the file that allows us to use the technologies we want to use with Maven. The technologies we want to use here are specified as &lt;dependency&gt; technology information to be used &lt;/dependency&gt; between &lt;dependencies&gt; &lt;/dependencies&gt; tags.</p><p>Below I will show you how to write these and the versions I use. However, if you want to use different versions or different technologies, you can access the versions you want from this site <a href="https://mvnrepository.com/">https://mvnrepository.com/</a> .If you want to follow what is done in this article, I recommend you use the versions I used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*TUcjRsXYl04gsZ04RnJzaw.png" /></figure><p>If you want to use it the way I use it, you can use it by copy-pasting the code block I will leave below. Afterwards, all you have to do is reload Maven.</p><pre>   &lt;dependencies&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;io.appium&lt;/groupId&gt;<br>            &lt;artifactId&gt;java-client&lt;/artifactId&gt;<br>            &lt;version&gt;7.6.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.testng&lt;/groupId&gt;<br>            &lt;artifactId&gt;testng&lt;/artifactId&gt;<br>            &lt;version&gt;7.7.1&lt;/version&gt;<br>            &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;<br>            &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;<br>            &lt;version&gt;3.141.59&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;com.aventstack&lt;/groupId&gt;<br>            &lt;artifactId&gt;extentreports&lt;/artifactId&gt;<br>            &lt;version&gt;5.1.0&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>            &lt;scope&gt;test&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;<br>            &lt;artifactId&gt;log4j-core&lt;/artifactId&gt;<br>            &lt;version&gt;2.14.1&lt;/version&gt;<br>        &lt;/dependency&gt;<br><br>        &lt;dependency&gt;<br>            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;<br>            &lt;artifactId&gt;lombok&lt;/artifactId&gt;<br>            &lt;version&gt;1.18.26&lt;/version&gt;<br>            &lt;scope&gt;provided&lt;/scope&gt;<br>        &lt;/dependency&gt;<br><br>    &lt;/dependencies&gt;</pre><p>Now we are one step closer to completing our project.</p><h3>What is what?</h3><p>Now, let’s see what the final version will be like when we create our project with its classes. The reason I show you directly here is to explain how our project will work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*lpldwROVwTYmBPhD3E-83Q.png" /></figure><p>First, let’s talk about what Base Page and Base Test classes are. Our Base Page class is the class that extends the pages we will create. This class contains common functions that we will use throughout the project. For example, to click a button;</p><pre>public void clickToElement(WebElement key){<br>        key.click();<br>    }</pre><p>We specify the command in this class. Such general-use functions are located in our Base Page class.</p><p>Our Base Test class is the class that defines the necessary parameters and capabilities for testing our test classes with the Appium driver and enables the test to be started and terminated. So, if we say Base Page is the heart, we can say that the Base Test class is the brain for us.</p><p>The pages to be tested are written separately in the pageObjects package within the “Framework” package. For example, if an application has a homepage and user page, these are specified in different classes. In this way, the elements we find for the pages and the operations to be performed on the pages are written separately, making code tracking easier. This is one of the best uses of the POM design pattern. On the pageTests side, if the page to be tested is the homepage, the test steps of the test to be performed on that page are written and our tests are carried out in these classes.</p><p>There are 3 packages located under the utils package. These are extentReport, listeners and logs packages. In fact, the classes we use here are not necessary for our test to run. But every test must have a result, and this result must be easily observable and analysable. TestNG has its own reporting functions, but they are not very useful. For this reason, I wanted to use extenReport and log as a 3rd party software. In this way, we can make our test reports more understandable and analysable.I will not go into detail about the content of the classes here later in the article. I will only describe the necessary sides because different research can be done about this side from different sources. Here, while the extent report allows us to report beautifully, we need to have a class that will give this information to the extent report. We use the TestListener class, which indicates whether the test has started, finished, failed or passed. And if the test fails, we use the retry and annotationtransformer classes, which allow us to test again. In fact, they all get their test information from the TestListener class. Our Log class is the class we use to keep the logging that we know is always used. I will explain the necessary information about the utils package and its contents in the later part of the article, apart from that, I will give you resources that you can follow for the remaining parts.</p><p>In our Resources package, we ensure that the information we need for testing is used from this side. For example, in our config.properties file, if we need a user email or password during testing, we get it from this step. In this way, it allows us to easily test different users. The exten.properties file contains the information that the extent report should use when creating it. Likewise, the log4j2.properties file contains the information that determines the format of our log file.</p><p>And finally, our testng.xml file is the file where the parameters used in our tests are determined and which test classes will be tested. We can call Base Page the heart, Base Test the brain, and testng.xml the vein. The blood required for our test is transported thanks to this file.</p><p>I know this part is a bit long, but it can be a little difficult to explain why we use the POM design pattern and how to use it. I chose this method of explanation because I thought it would be more understandable to explain all directories and packages one by one. Now that the boring part is over, we can move on to the coding part.</p><h3>Coding</h3><p>First of all, I want to start this section with Base Test. Because we cannot live without the brain.</p><h4>Base Test</h4><p>We can say that the Base Test class consists of 3 parts. These can be divided into 3 groups: creating objects, creating the driver and giving the capabilities, and reading the BeforeMethod and property file.</p><pre>public class BaseTest {<br><br>    public AppiumDriver driver;<br><br>    //PAGES<br>    public HomePageObjects homePageObjects;<br>    public LoginPageObjects loginPageObjects;<br><br><br>    public Properties properties;<br>    FileInputStream fileInputStream;<br>    public DesiredCapabilities capabilities;<br><br><br>    public AppiumDriver getDriver(){return driver;}</pre><p>In this part, we create our objects.</p><pre>@Parameters({&quot;platformName&quot;,&quot;udid&quot;,&quot;appPackage&quot;,&quot;appActivity&quot;,&quot;implicityWait&quot;})<br>    @BeforeClass(alwaysRun = true)<br>    public void setup(String platformName,String udid, String appPackage, String appActivity, String implicityWait) throws Exception{<br>        capabilities = new DesiredCapabilities();<br><br>        if(platformName.equals(&quot;Android&quot;)){<br>            capabilities.setCapability(&quot;platformName&quot;,&quot;Android&quot;);<br>            capabilities.setCapability(&quot;udid&quot;,udid);<br>            capabilities.setCapability(&quot;appPackage&quot;,appPackage);<br>            capabilities.setCapability(&quot;appActivity&quot;,appActivity);<br>        }<br>        else if(platformName.equals(&quot;IOS&quot;)){<br>            capabilities.setCapability(&quot;platformName&quot;,&quot;IOS&quot;);<br>            capabilities.setCapability(&quot;udid&quot;,udid);<br>            capabilities.setCapability(&quot;appPackage&quot;,appPackage);<br>            capabilities.setCapability(&quot;appActivity&quot;,appActivity);<br>        }<br>        try {<br>            URL url = new URL(&quot;http://0.0.0.0:4723/wd/hub&quot;);<br>            Log.info(&quot;Test başlıyor!&quot;);<br>            driver = new AppiumDriver&lt;MobileElement&gt;(url,capabilities);<br>            //driver = new AndroidDriver&lt;MobileElement&gt;(url,capabilities);<br>            //driver = new IOSDriver&lt;MobileElement&gt;(url,capabilities);<br>        } catch (MalformedURLException e) {<br>            e.printStackTrace();<br>        }<br>        int impWait = Integer.parseInt(implicityWait);<br>        driver.manage().timeouts().implicitlyWait(impWait, TimeUnit.SECONDS);<br>        //return getDriver();<br>    }</pre><p>In this section, we specify our capability values and url values required for the Appium driver to work. And we specify an implicity time for our driver.</p><pre>@BeforeMethod(alwaysRun = true)<br>    public void methodSetup() throws IOException {<br>        getReadPropFile();<br>        homePageObjects = new HomePageObjects(driver);<br>        loginPageObjects = new LoginPageObjects(driver);<br>    }<br><br>    public void getReadPropFile() throws IOException {<br>        properties = new Properties();<br>        fileInputStream = new FileInputStream(&quot;src/test/resources/config.properties&quot;);<br>        properties.load(fileInputStream);<br>    }<br><br>    @AfterClass(alwaysRun = true)<br>    public void teardown() {<br>        Log.info(&quot;Test bitti.&quot;);<br>        driver.quit();}<br>}</pre><p>Finally, before the test starts, we add the pages to be tested, the properties file from which the information will be obtained, and the sections that allow the driver to be stopped after the test is completed. And in this way, our code written for Base Test is exactly as follows.</p><pre>public class BaseTest {<br><br>    public AppiumDriver driver;<br><br>    //PAGES<br>    public HomePageObjects homePageObjects;<br>    public LoginPageObjects loginPageObjects;<br><br><br>    public Properties properties;<br>    FileInputStream fileInputStream;<br>    public DesiredCapabilities capabilities;<br><br><br>    public AppiumDriver getDriver(){return driver;}<br>    @Parameters({&quot;platformName&quot;,&quot;udid&quot;,&quot;appPackage&quot;,&quot;appActivity&quot;,&quot;implicityWait&quot;})<br>    @BeforeClass(alwaysRun = true)<br>    public void setup(String platformName,String udid, String appPackage, String appActivity, String implicityWait) throws Exception{<br>        capabilities = new DesiredCapabilities();<br><br>        if(platformName.equals(&quot;Android&quot;)){<br>            capabilities.setCapability(&quot;platformName&quot;,&quot;Android&quot;);<br>            capabilities.setCapability(&quot;udid&quot;,udid);<br>            capabilities.setCapability(&quot;appPackage&quot;,appPackage);<br>            capabilities.setCapability(&quot;appActivity&quot;,appActivity);<br>        }<br>        else if(platformName.equals(&quot;IOS&quot;)){<br>            capabilities.setCapability(&quot;platformName&quot;,&quot;IOS&quot;);<br>            capabilities.setCapability(&quot;udid&quot;,udid);<br>            capabilities.setCapability(&quot;appPackage&quot;,appPackage);<br>            capabilities.setCapability(&quot;appActivity&quot;,appActivity);<br>        }<br>        try {<br>            URL url = new URL(&quot;http://0.0.0.0:4723/wd/hub&quot;);<br>            Log.info(&quot;Test başlıyor!&quot;);<br>            driver = new AppiumDriver&lt;MobileElement&gt;(url,capabilities);<br>            //driver = new AndroidDriver&lt;MobileElement&gt;(url,capabilities);<br>            //driver = new IOSDriver&lt;MobileElement&gt;(url,capabilities);<br>        } catch (MalformedURLException e) {<br>            e.printStackTrace();<br>        }<br>        int impWait = Integer.parseInt(implicityWait);<br>        driver.manage().timeouts().implicitlyWait(impWait, TimeUnit.SECONDS);<br>        //return getDriver();<br>    }<br><br>    @BeforeMethod(alwaysRun = true)<br>    public void methodSetup() throws IOException {<br>        getReadPropFile();<br>        homePageObjects = new HomePageObjects(driver);<br>        loginPageObjects = new LoginPageObjects(driver);<br>    }<br><br>    public void getReadPropFile() throws IOException {<br>        properties = new Properties();<br>        fileInputStream = new FileInputStream(&quot;src/test/resources/config.properties&quot;);<br>        properties.load(fileInputStream);<br>    }<br><br>    @AfterClass(alwaysRun = true)<br>    public void teardown() {<br>        Log.info(&quot;Test bitti.&quot;);<br>        driver.quit();}<br>}</pre><h4>Base Page</h4><p>Now, we do not need to divide it into parts as in the Base Test class. Here the class consists of 2 parts. Creating the driver we will use and entering its information and the functions to be used throughout the test. I will send this class directly below with all its codes. There is nothing to explain here, the functions listed below may vary from project to project. Most of the functions written here will not be used for this project. There are functions written purely for example purposes, you can change or remove these functions as you wish and as needed. Likewise, you can add your own functions.</p><pre>public class BasePage {<br>    AppiumDriver driver;<br>    WebDriverWait wait;<br>    Actions action;<br><br>    public BasePage(AppiumDriver driver){<br>        this.driver = driver;<br>        this.wait = new WebDriverWait(driver, 10);<br>        this.action = new Actions(driver);<br><br>    }<br><br>    public WebElement findElement(By key){<br>        WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(key));<br>        return element;<br>    }<br><br><br>    public void clickToElement(By key){<br>        findElement(key).click();<br>        waitForSecond(2);<br>    }<br>    public void clickToElement(WebElement key){<br>        key.click();<br>    }<br><br>    public void sendKeysToElement(By key,String text){<br>        findElement(key).sendKeys(text);<br>    }<br><br>    public boolean checkElementIfVisibleTrue(By key){<br>        wait.until(ExpectedConditions.presenceOfElementLocated(key));<br>        return true;<br>    }<br><br>    public void checkElementIfExist(By key){<br>        if(findElement(key) != null){<br>            Assert.assertTrue(true,&quot;Element is found&quot;);<br>        }<br>        else if(findElement(key) == null){<br>            Assert.assertFalse(true,&quot;Element cannot find&quot;);<br>        }<br>    }<br><br>    public void scroolDownUntilFindTheElement(By key){<br><br>        int maxRetryCount = 10;<br>        while (maxRetryCount &gt; 0) {<br>            try {<br>                if (checkElementIfVisibleTrue(key)) {<br>                    break;<br>                }<br>            }catch (Exception e){<br>                maxRetryCount--;<br>                new TouchAction(driver)<br>                    .press(PointOption.point(506, 1829))<br>                    .waitAction(waitOptions(ofMillis(1000)))<br>                    .moveTo(PointOption.point(506, 1285))<br>                    .release()<br>                    .perform();<br>                if (maxRetryCount == 0) {<br>                    Assert.assertFalse(false,&quot;Element cannot find&quot;);<br>                    break;<br>                }<br>            }<br>        }<br><br>    }<br><br>    public void scroolDownUntilFindTheElement(WebElement key){<br><br>        int maxRetryCount = 10;<br>        while (maxRetryCount &gt; 0) {<br>            try {<br>                if (key.isEnabled()) {<br>                    break;<br>                }<br>            }catch (Exception e){<br>                maxRetryCount--;<br>                new TouchAction(driver)<br>                    .press(PointOption.point(506, 1829))<br>                    .waitAction(waitOptions(ofMillis(1000)))<br>                    .moveTo(PointOption.point(506, 1285))<br>                    .release()<br>                    .perform();<br>                if (maxRetryCount == 0) {<br>                    Assert.assertFalse(false,&quot;Element cannot find&quot;);<br>                    break;<br>                }<br>            }<br>        }<br><br>    }<br><br><br><br>    public void swipeToLeftNTime(Integer swipeCount){<br><br>        int maxRetryCount = swipeCount;<br>        while (maxRetryCount &gt; 0) {<br>            maxRetryCount--;<br>            new TouchAction(driver)<br>                .press(PointOption.point(850, 1100))<br>                .waitAction(waitOptions(ofMillis(1000)))<br>                .moveTo(PointOption.point(330, 1100))<br>                .release()<br>                .perform();<br>            if (maxRetryCount == 0) {<br>                System.out.println(&quot;Swipe is over.&quot;);<br>                break;<br>            }<br><br>        }<br><br>    }<br><br>    public void waitForSecond(int seconds) {<br>        try {<br>            Thread.sleep(seconds*1000);<br>        } catch (InterruptedException e) {<br>            e.printStackTrace();<br>        }<br>    }<br><br>    public void clickElementIfExists(By key) {<br>        try{<br>            if(checkElementIfVisibleTrue(key)){<br>                clickToElement(key);<br>            }<br>        }catch (Exception e){<br>            System.out.println(&quot;Element bulunamadı&quot;);<br>        }<br>    }<br><br>    public void deviceGoBack(){<br>        driver.navigate().back();<br>    }<br><br>    public void emptyTab(){<br>        action.click();<br>    }<br><br>    protected String getInfoMessage(String message) {<br>        ExtentTestManager.getTest().log(Status.INFO, message);<br>        return message;<br>    }<br>}</pre><h4>HomePageObjects and LoginPageObjects</h4><p>We will discuss the classes mentioned here together because the formats of the pages will always be the same. In these classes, you can create different classes for different applications you will test and increase the number of pages to be tested. These classes extend from the BasePage class, and the functions used within the functions are used by BasePage. These classes always consist of 3 sections. These are specifying the driver to be used, specifying the elements and specifying the functions to be used for testing.</p><pre>public class HomePageObjects extends BasePage {<br><br>    public HomePageObjects(AppiumDriver driver) {super(driver);}<br><br>    By userIcon = By.id(&quot;com.turknet.oim:id/tv_user_short_cut&quot;);<br><br>    public HomePageObjects checkHomePage(){<br>        checkElementIfExist(userIcon);<br>        return this;<br>    }<br>}</pre><pre>public class LoginPageObjects extends BasePage {<br><br>    public LoginPageObjects(AppiumDriver driver) {<br>        super(driver);<br>    }<br><br>    By tcField = By.id(&quot;com.turknet.oim:id/et_login_tckn&quot;);<br>    By passwordField = By.id(&quot;com.turknet.oim:id/et_login_password&quot;);<br>    By loginButton = By.id(&quot;com.turknet.oim:id/btn_login&quot;);<br><br>    public LoginPageObjects checkTCField(){<br>        checkElementIfExist(tcField);<br>        return this;<br>    }<br><br>    public LoginPageObjects checkPasswordField(){<br>        checkElementIfExist(passwordField);<br>        return this;<br>    }<br><br>    public LoginPageObjects loginToAccount(String tcNo, String password){<br>        sendKeysToElement(tcField,tcNo);<br>        sendKeysToElement(passwordField,password);<br>        clickElementIfExists(loginButton);<br>        return this;<br><br>    }<br>}</pre><h4>HomeTest</h4><p>First of all, I need to explain what will be tested here. After logging in to the mobile application called Türknet, the user accesses the home page. And if the user can see the icon on the home page, it detects that he has accessed the home page and passes the test as a pass.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*lkDposL3A0y1EWSJ5rZgfQ.png" /></figure><p>Here the user enters his/her ID number and password, clicks the continue button and logs in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*8h2NBZQDOCjeuLyxlOiDeA.png" /></figure><p>If the icon shown with a red arrow appears on the home page after logging in, you have logged in successfully and reached the home page. Test pass is given. Now let’s see how this is accomplished within the HomeTest class.</p><pre>public class HomeTest extends BaseTest {<br>    @BeforeMethod<br>    public void loginToAccount(Method method){<br>        startTest(method.getName(),&quot;Ana sayfanın açılması ve kontrolü&quot;);<br>        loginPageObjects.loginToAccount(properties.getProperty(&quot;tcNo&quot;),properties.getProperty(&quot;password&quot;));<br><br><br>    }<br><br>    @Test(priority = 0, description = &quot;Check home page&quot;)<br>    public void checkHomePage(){<br>        homePageObjects.checkHomePage();<br><br>    }<br><br><br>}</pre><p>Here, in the BeforeMethod section, the user gets the required ID number and password from config.properties and logs in with the help of the loginToAccount function in loginPageObjects. You can see how the loginToAccount function works in the LoginPageObjects we mentioned above. After the user logs in, the checkHomePage function used in homePageObjects checks whether the user icon exists. If there is, our test is passed. Again, you can see how the checkHomePage function works from the codes we specified in HomePageObjects.</p><p>Another important issue here is the startTest function. Thanks to this function, ExtentTestManager learns that the test has started, and TestListener can follow the steps of the test with the getTest function in ExtentTestManager and use it for both Retry and ExtentReport. I will not explain the codes here in detail, I just explained why we used the startTest method. Those who want to examine these codes in more detail can look at this page <a href="https://www.swtestacademy.com/extent-reports-in-selenium-with-testng/">https://www.swtestacademy.com/extent-reports-in-selenium-with-testng/</a></p><h4>All Utils</h4><p>I will not explain the codes in detail here because this part is a different part that is far from our topic. I have given the necessary link for this section in the line above, you can see the rest here, but I will give the codes in this section so that the reporting of the project works correctly. You can copy and paste these codes.</p><h4>ExtentManager</h4><pre>public class ExtentManager {<br>    public static final ExtentReports extentReports = new ExtentReports();<br>    public synchronized static ExtentReports createExtentReports() {<br>        ExtentSparkReporter reporter = new ExtentSparkReporter(&quot;./extent-reports/extent-report.html&quot;);<br>        reporter.config().setReportName(&quot;Turknet Extent Report&quot;);<br>        extentReports.attachReporter(reporter);<br>        extentReports.setSystemInfo(&quot;Turknet&quot;, &quot;Mobile Test&quot;);<br>        extentReports.setSystemInfo(&quot;Author&quot;, &quot;Bakican Boydas&quot;);<br>        return extentReports;<br>    }<br>}</pre><h4>ExtentTestManager</h4><pre>public class ExtentTestManager {<br>    static Map&lt;Integer, ExtentTest&gt; extentTestMap = new HashMap&lt;&gt;();<br>    static ExtentReports            extent        = ExtentManager.createExtentReports();<br>    public static synchronized ExtentTest getTest() {<br>        return extentTestMap.get((int) Thread.currentThread().getId());<br>    }<br>    public static synchronized ExtentTest startTest(String testName, String desc) {<br>        ExtentTest test = extent.createTest(testName, desc);<br>        extentTestMap.put((int) Thread.currentThread().getId(), test);<br>        return test;<br>    }<br>}</pre><h4>AnnotationTransformer</h4><pre>public class AnnotationTransformer implements IAnnotationTransformer {<br>    @Override<br>    public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {<br>        annotation.setRetryAnalyzer(Retry.class);<br>    }<br>}</pre><h4>Retry</h4><pre>public class Retry implements IRetryAnalyzer {<br>    private        int count  = 0;<br>    private static int maxTry = 1; //Run the failed test 2 times<br><br>    @Override<br>    public boolean retry(ITestResult iTestResult) {<br>        if (!iTestResult.isSuccess()) {                     //Check if test not succeed<br>            if (count &lt; maxTry) {                           //Check if maxTry count is reached<br>                count++;                                    //Increase the maxTry count by 1<br>                iTestResult.setStatus(ITestResult.FAILURE); //Mark test as failed and take base64Screenshot<br>                extendReportsFailOperations(iTestResult);   //ExtentReports fail operations<br>                return true;                                //Tells TestNG to re-run the test<br>            }<br>        } else {<br>            iTestResult.setStatus(ITestResult.SUCCESS);     //If test passes, TestNG marks it as passed<br>        }<br>        return false;<br>    }<br><br>    public void extendReportsFailOperations(ITestResult iTestResult) {<br>        Object testClass = iTestResult.getInstance();<br>        WebDriver webDriver = ((BaseTest) testClass).getDriver();<br>        String base64Screenshot = &quot;data:image/png;base64,&quot; + ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.BASE64);<br>        getTest().log(Status.FAIL, &quot;Test Failed&quot;,<br>            getTest().addScreenCaptureFromBase64String(base64Screenshot).getModel().getMedia().get(0));<br>    }<br>}</pre><h4>TestListener</h4><pre>public class TestListener extends BaseTest implements ITestListener {<br>    private static String getTestMethodName(ITestResult iTestResult) {<br>        return iTestResult.getMethod().getConstructorOrMethod().getName();<br>    }<br><br>    @Override<br>    public void onStart(ITestContext iTestContext) {<br>        Log.info(&quot;I am in onStart method &quot; + iTestContext.getName());<br>        iTestContext.setAttribute(&quot;AppiumDriver&quot;, this.driver);<br>    }<br><br>    @Override<br>    public void onFinish(ITestContext iTestContext) {<br>        Log.info(&quot;I am in onFinish method &quot; + iTestContext.getName());<br>        //Do tier down operations for ExtentReports reporting!<br>        ExtentManager.extentReports.flush();<br>    }<br><br>    @Override<br>    public void onTestStart(ITestResult iTestResult) {<br>        Log.info(getTestMethodName(iTestResult) + &quot; test is starting.&quot;);<br>    }<br><br>    @Override<br>    public void onTestSuccess(ITestResult iTestResult) {<br>        Log.info(getTestMethodName(iTestResult) + &quot; test is succeed.&quot;);<br>        //ExtentReports log operation for passed tests.<br>        getTest().log(Status.PASS, &quot;Test passed&quot;);<br>    }<br><br>    @Override<br>    public void onTestFailure(ITestResult iTestResult) {<br>        Log.info(getTestMethodName(iTestResult) + &quot; test is failed.&quot;);<br><br>        //Get driver from BaseTest and assign to local webdriver variable.<br>        Object testClass = iTestResult.getInstance();<br>        WebDriver driver = ((BaseTest) testClass).getDriver();<br><br>        //Take base64Screenshot screenshot for extent reports<br>        String base64Screenshot =<br>            &quot;data:image/png;base64,&quot; + ((TakesScreenshot) Objects.requireNonNull(driver)).getScreenshotAs(OutputType.BASE64);<br><br>        //ExtentReports log and screenshot operations for failed tests.<br>        getTest().log(Status.FAIL, &quot;Test Failed&quot;,<br>            getTest().addScreenCaptureFromBase64String(base64Screenshot).getModel().getMedia().get(0));<br>    }<br><br>    @Override<br>    public void onTestSkipped(ITestResult iTestResult) {<br>        Log.info(getTestMethodName(iTestResult) + &quot; test is skipped.&quot;);<br>        //ExtentReports log operation for skipped tests.<br>        getTest().log(Status.SKIP, &quot;Test Skipped&quot;);<br>    }<br><br>    @Override<br>    public void onTestFailedButWithinSuccessPercentage(ITestResult iTestResult) {<br>        Log.info(&quot;Test failed but it is in defined success ratio &quot; + getTestMethodName(iTestResult));<br>    }</pre><h4>Log</h4><pre>public class Log {<br>    //Initialize Log4j instance<br>    private static final Logger Log =  LogManager.getLogger(Log.class);<br><br>    //Info Level Logs<br>    public static void info (String message) {<br>        Log.info(message);<br>    }<br><br>    //Warn Level Logs<br>    public static void warn (String message) {<br>        Log.warn(message);}<br>        //Error Level Logs<br>        public static void error (String message) {<br>            Log.error(message);<br>        }<br><br>        //Fatal Level Logs<br>        public static void fatal (String message) {<br>            Log.fatal(message);<br>        }<br><br>        //Debug Level Logs<br>        public static void debug (String message) {<br>            Log.debug(message);<br>        }<br>    }</pre><h4>Resources</h4><p>The only file we need here is the config.properties file. Other files are the files that specify how the reporting formats will be. The config file is the file where the information we need during the test is written. The config file will be as follows. You can add any extra information you want here when you will use it in your test.</p><pre>tcNo = ID number will be written here<br>password = The password will be written here too.</pre><p>extent.properties</p><pre>extent.reporter.spark.start=true<br>extent.reporter.spark.out=Reports/Spark.html</pre><p>log4j2.properties</p><pre>#Declare loggers<br>status = error<br>name= Log4j2PropertiesConfig<br>appenders=a_console, a_rolling<br>rootLogger.level=info<br>rootLogger.appenderRefs = ar_console,ar_rolling<br>rootLogger.appenderRef.ar_console.ref = StdoutAppender<br>rootLogger.appenderRef.ar_rolling.ref= RollingAppender<br><br>#Console Logger<br>appender.a_console.type = Console<br>appender.a_console.name = StdoutAppender<br>appender.a_console.layout.type = PatternLayout<br>appender.a_console.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n<br><br>#Rolling Logger<br>appender.a_rolling.type = RollingFile<br>appender.a_rolling.name = RollingAppender<br>appender.a_rolling.layout.pattern = [%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n<br>appender.a_rolling.fileName=log4j2/log4j2-test-automation.log<br>appender.a_rolling.filePattern=log4j2-sample-%d{yyyy-MM-dd}.log<br>appender.a_rolling.layout.type = PatternLayout<br>appender.a_rolling.policies.type = Policies<br>appender.a_rolling.policies.time.type = TimeBasedTriggeringPolicy<br>appender.a_rolling.policies.time.interval = 1<br><br># To change log file every day<br>appender.a_rolling.policies.time.modulate = true<br># To change log file after 10MB size<br>appender.a_rolling.policies.size.type = SizeBasedTriggeringPolicy<br>appender.a_rolling.policies.size.size=10MB<br>appender.a_rolling.strategy.type = DefaultRolloverStrategy<br>appender.a_rolling.strategy.max = 20</pre><h4>testng.xml</h4><p>And finally, it’s time to create our testng.xml file where we will run our project. This file consists of 3 parts. These are listeners, parameter and class sections. In the Listener section, we specify the listener files we will use for our test. In the parameter section, we specify the device information and package information, and in the class section, we specify which test class we will test. We have a single test class for this project, but if we had more test classes, we could test them as a package. xml file is as follows.</p><pre>&lt;suite name=&quot;Turknet Test Suite&quot;&gt;<br><br>    &lt;listeners&gt;<br>        &lt;listener class-name=&quot;utils.listeners.TestListener&quot;/&gt;<br>        &lt;listener class-name=&quot;utils.listeners.AnnotationTransformer&quot;/&gt;<br>    &lt;/listeners&gt;<br>    &lt;test name=&quot;Turknet Tests&quot;&gt;<br>        &lt;parameter name=&quot;platformName&quot; value=&quot;Android&quot;&gt;&lt;/parameter&gt;<br>        &lt;parameter name=&quot;udid&quot; value=&quot;R5CT62X6DNM&quot;&gt;&lt;/parameter&gt;<br>        &lt;parameter name=&quot;appPackage&quot; value=&quot;com.turknet.oim&quot;&gt;&lt;/parameter&gt;<br>        &lt;parameter name=&quot;appActivity&quot; value=&quot;com.turknet.oim.features.loginotp.presentation.login.LoginActivity&quot;&gt;&lt;/parameter&gt;<br>        &lt;parameter name=&quot;implicityWait&quot; value=&quot;10&quot;&gt;&lt;/parameter&gt;<br>        &lt;classes&gt;<br>            &lt;class name=&quot;Framework.pageTests.HomeTest&quot;&gt;&lt;/class&gt;<br>        &lt;/classes&gt;<br>    &lt;/test&gt;<br>&lt;/suite&gt;</pre><h3>Start the test and view results</h3><p>We right-click on the testng.xml file and start our test as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*najSoAJ0EykxTr0g-G9MjA.png" /></figure><p>After the test is completed, you can see the result as in the image below. After the test is completed, two different files named extent-reports and log4j2 will be created and you will be able to view the test report in these files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iYOPjZcpodFXXrA2j7I0nw.png" /></figure><h3>And the scene closes…</h3><p>I hope this article will be useful for everyone. The projects and articles were created entirely by me and a lot of effort was spent. Please share this effort of mine with those who want to learn this business. Knowledge gets better as it is shared.</p><h3>Project Github Link</h3><p><a href="https://github.com/bakicanboydas/turknetMobileTest">GitHub - bakicanboydas/turknetMobileTest</a></p><h3>Sources used in the creation of this article</h3><p><a href="https://github.com/appium/appium-desktop/releases">https://github.com/appium/appium-desktop/releases</a><br><a href="https://www.jetbrains.com/idea/download/?section=windows">https://www.jetbrains.com/idea/download/?section=windows</a><br><a href="https://developer.android.com/tools/releases/platform-tools">https://developer.android.com/tools/releases/platform-tools</a><br><a href="https://maven.apache.org/download.cgi">https://maven.apache.org/download.cgi</a><br><a href="https://www.oracle.com/tr/java/technologies/downloads/">https://www.oracle.com/tr/java/technologies/downloads/</a><br><a href="https://mvnrepository.com/">https://mvnrepository.com/</a><br><a href="https://www.swtestacademy.com/extent-reports-in-selenium-with-testng/">https://www.swtestacademy.com/extent-reports-in-selenium-with-testng/</a><br><a href="https://github.com/bakicanboydas/turknetMobileTest">https://github.com/bakicanboydas/turknetMobileTest</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e343365e5bc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>