25 Mayıs 2017 Perşembe

block hulk

I just bumped on this thread and noticed that it have 2 down votes. Anyway, I just want to post what I did to block HULK requests.
In /etc/nginx/conf.d/default.conf (or similar). I added the following inside the server block:
if ($args ~* "(.{1,})=(.{1,})" ){
        rewrite ^/$ /444_rewrite?;
}
location  /444_rewrite {
        return 444;
}
What it does? Since the site is using friendly URL and none of the site URL starts with ? and =, I can redirect all those weird GET requests to 444. The argument (.{1,})=(.{1,}) tells Nginx to redirect all GET requests that have any characters with = between them.

selenium disable devoloper extension

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-extensions");
driver = new ChromeDriver(options);


ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
System.setProperty("webdriver.chrome.driver",(System.getProperty("user.dir") + "//src//test//resources//chromedriver_new.exe"));
driver = new ChromeDriver(options);



The official way to disable the popup seems to be like this:
  1. Pack your extension and install it via drag-and-dropping the .crx file into the chrome://extensions page.
    (you'll get an "Unsupported extensions disabled" popup if you try restarting Chrome at this stage)
Then for Win7/8:
  1. Download Chrome group policy templates from: http://dl.google.com/dl/edgedl/chrome/policy/policy_templates.zip
  2. Copy [zip]\windows\admx\chrome.admx to c:\windows\policydefinitions
  3. Copy [zip]\windows\admx\[yourlanguage]\chrome.adml to c:\windows\policydefinitions\[yourlanguage]\chrome.adml (not c:\windows\[yourlanguage])
  4. In Chrome, go to Settings > Extensions
  5. Check the Developer Mode checkbox at the top
  6. Scroll down the list of disabled extensions and note the ID(s) of the extensions you want to enable. LogMeIn, for example, is ID: nmgnihglilniboicepgjclfiageofdfj
  7. Click Start > Run, and type gpedit.msc <ENTER>
  8. Expand User Configuration > Administrative Templates > Google Chrome > Extensions
  9. Double-click to open Configure extension installation whitelist policy
  10. Select Enabled, then click Show...
  11. In the list, enter the ID(s) of the extensions you noted in Step 7
  12. Click OK and restart Chrome.
That's it!
I worked around this issue by using AutoIT.
First, you'll need to create the script.
closechromewarning.au3:
WinWaitActive("[CLASS:Chrome_WidgetWin_1]")
Send("{ESC}")
The script needs to be compiled to a .exe, then place the .exe in the path so it can be run.
Function that closes the warning, using c# syntax:
public void CloseChromeDialog()
{
    System.Threading.Thread.Sleep(5000);
    Process.Start(@".\closechromewarning.exe");
}
Sleep(4000) did work, but I upped it to Sleep(5000) just to be sure.
Calling CloseChromeDialog():
if(browser == chrome) //pseudo code
    CloseChromeDialog();

2 Şubat 2017 Perşembe

selenium xpath example

driver.findElement(By.xpath("/html/body/div/input[1]")).sendKeys("123");

driver.findElement(By.xpath("//input[1]")).click();

driver.findElement(By.xpath("(//input[1])[4])")).click();

driver.findElement(By.xpath("//tag[@AN='AV']")).sendKeys("123");

driver.findElement(By.xpath("//tag[text()='AV']")).sendKeys("123");

driver.findElement(By.xpath("//tag[@AN='AV' and @AN='AV']")).click();




driver.findElement(By.xpath("//tag[contains(text(),'usrn')]").getText();

driver.findElement(By.xpath("//tag[contains(@AN,'usrn')]").getText();

driver.findElement(By.xpath("//tag[starts-with(text(),'usrn')]").getText();
driver.findElement(By.xpath("//tag[starts-with(@AN,'usrn')]").getText();

1 Ocak 2017 Pazar

Dll load dynamic and reflection



Reflection
namespace ConsoleApplication1
{
    using System;
    using System.Reflection;

    class Program
    {
        static void Main(string[] args)
        {
            var DLL = Assembly.LoadFile(@"C:\visual studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\DLL.dll");

            foreach(Type type in DLL.GetExportedTypes())
            {
                var c = Activator.CreateInstance(type);
                type.InvokeMember("Output", BindingFlags.InvokeMethod, null, c, new object[] {@"Hello"});
            }

            Console.ReadLine();
        }
    }
}
Dynamic (.NET 4.0)
namespace ConsoleApplication1
{
    using System;
    using System.Reflection;

    class Program
    {
        static void Main(string[] args)
        {
            var DLL = Assembly.LoadFile(@"C:\visual studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\DLL.dll");

            foreach(Type type in DLL.GetExportedTypes())
            {
                dynamic c = Activator.CreateInstance(type);
                c.Output(@"Hello");
            }

            Console.ReadLine();
        }
    }
}

Inject Data Of .Net File In Current Project Using New Method

Inject Data Of .Net File In Current Project Using New Method

Assembly obj = Assembly.Load(My.Resources.Server);
object @ref = obj.CreateInstance("j.A");
Interaction.CallByName(@ref, "main", CallType.Method);

16 Aralık 2016 Cuma

selenium scroll

driver.get("http://www.flipkart.com/");
driver.manage().window().maximize();
driver.findElement(By.linkText("Trimmer")).click();
WebElement scroll = driver.findElement(By.id("brand"));
scroll.sendKeys(Keys.PAGE_DOWN);