20 Kasım 2016 Pazar

selenium google href almak

public static void main(String[] args) {

    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("Cheese!\n"); // send also a "\n"
    element.submit();

    // wait until the google page shows the result
    WebElement myDynamicElement = (new WebDriverWait(driver, 10))
              .until(ExpectedConditions.presenceOfElementLocated(By.id("resultStats")));

    List<WebElement> findElements = driver.findElements(By.xpath("//*[@id='rso']//h3/a"));

    // this are all the links you like to visit
    for (WebElement webElement : findElements)
    {
        System.out.println(webElement.getAttribute("href"));
    }
}

17 Kasım 2016 Perşembe

selenium focus

WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById('elementid').focus();");

14 Kasım 2016 Pazartesi

c# selenium youtube

 var dir1 = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            //var dir = dir1 + "\\Default\\cookies";
            //File.Copy(yol, dir, true);

            //var chromedir = @"C:/Users/" + username + "/AppData/Local/Google/Chrome/User Data/";
            //copy(yol,dir);

            //MessageBox.Show(dir1);
            //Yeni.TopMost = true;

            ChromeOptions opt = new ChromeOptions();
            opt.AddArguments("--user-data-dir=" + dir1);
            var driver = new ChromeDriver(opt);



            driver.Navigate().GoToUrl("https://www.youtube.com/watch?v=YprmIsKN4XI&nohtml5=False");

            //driver.FindElement(By.ClassName("yt-uix-button-content")).Click();
            driver.FindElement(By.XPath("//span[contains(., \"Daha fazla\")]")).Click();

            //driver.FindElement(By.LinkText("Report")).Click();

            Thread.Sleep(5000);

            driver.FindElement(By.XPath("//span[contains(., \"Bildir\")]")).Click();
            Thread.Sleep(5000);

         
            driver.FindElement(By.XPath("//span[contains(., \"Cinsel içerik\")]")).Click();

            Thread.Sleep(5000);

            //driver.FindElement(By.XPath("//span[contains(., \"Birini seçin\")]")).Click();

            //Thread.Sleep(5000);
            //driver.FindElement(By.Id("id_dropdown_menu")).Click();

            //IWebElement sTag = driver.FindElement(By.Id("sel123"));
            //OpenQA.Selenium.Support.UI.SelectElement selectTag = new OpenQA.Selenium.Support.UI.SelectElement(sTag);
            //selectTag.SelectByValue("admin");
            //selectTag.SelectByIndex(3);

            driver.FindElement(By.ClassName("options-renderer-type-select")).FindElement(By.CssSelector("option[value='3']"));


            //driver.FindElement(By.XPath("//span[contains(., \"Müstehcen, ancak çıplaklık içermiyor\")]")).Click();

            Thread.Sleep(5000);


            driver.FindElement(By.XPath("//span[contains(., \"Gönder\")]")).Click();

12 Kasım 2016 Cumartesi

c# updater alternative

ClickOnce as a technology for keeping an application updated.  It worked as expected and was quick to implement because of the built-in support within Visual Studio.  However, the following issues kept me from using it:
  • ClickOnce application is not a normal application with a simple executable
  • ClickOnce application does not accept normal command-line arguments
  • ClickOnce application must be installed using a special application link
  • ClickOnce application requires special mime-types in IIS
  • ClickOnce application has slow startup when checking for updates
So I liked the ClickOnce update story but I hated that a ClickOnce application is special. So, I created an extremely simple updater with the goal of having the least code possible.  My simple updater does the following:
  • SimpleUpdater can check for updates at startup (in a separate thread for speed) or anytime on demand
  • SimpleUpdater downloads very simple remote XML manifest
  • SimpleUpdater will prompt user when there is an update available
  • SimpleUpdater downloads and extracts updated files and restarts updated application
SimpleUpdater is built with and requires the .NET 3.5 Client Profile.
Implementation Overview
  1. Add Updater.exe to your project
  2. Add Updater.cs code to your project
  3. Add UpdateForm to your project
  4. Call CheckForUpdates upon startup
  5. Add ShowUpdateDialog code to your main form
  6. (optional) Add manual check for update option to your main form
  7. Create and upload manifest and update zip to server
Updaterexe_thumb8.media  

Implementation Details
Update: I've added an example client app to the github
Step 1: Add Updater.exe to your project
Add the Updater.exe to your project and set build output to content and copy to output directory to copy if  newer.  The Updater.exe becomes another file that is deployed with your application.
Step 2: Add Updater.cs  and UpdateForm to your project
Copy these files into your project.  The UpdateForm is so simple that if you need to rewrite in XAML it should only take a few minutes.  Feel free to change the naming and namespaces to simplify things.
Also, add the following settings to your project (or hard-code if you like):
 UpdateSettings_thumb1.media
Step 3: Add startup code
Upon startup, usually in your Program.cs Main() method, call Updater.UpdateUpdater() to check for a new Updater.exe file.  Since the Updater.exe file was locked during update, the client app must rename the file.
Next, in your main form's load event, use a thread to call Updater.CheckForUpdates().
Image171.media  
Step 4: Add ShowUpdateDialog method to your main form
This code will extract the update details from the manifest document and show the UpdateForm as a dialog.
 Image18.media
Step 5: (optional) Add manual check for update
If the user does a manual check from the help menu, you may want to display a message box with the result.  Use this code:
Image_thumb91.media
Step 6: Create a manifest file
The App.manifest is extremely simple. It contains the update date, version, and links:
 Image25.media
I recommend you add this file to your project and set "build output" to "content" and "copy to output directory" to "copy if  newer".  Also, you can either automate the update of this file with each build or update it manually.  Each time you want to deploy an update, update the assembly version and update this manifest file.
Step 7: Deploy the update
Build your application and create a zip of the release files.  Copy the zip file and the manifest file to your server.
UpdateZipDeploy_thumb3.media
Simple Updater Source Code
I've put the simple updater source code on GitHub.  The updater application includes some code from the SharpZipLib for unzipping files.  Otherwise, the code is pretty simple.  I wrote around 200 lines of code for the updater application.
Credits

9 Kasım 2016 Çarşamba

c# play sound

private void playSoundFromResource(object sender, EventArgs e) 
{ 
    System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); 
    System.IO.Stream s = a.GetManifestResourceStream("<AssemblyName>.chimes.wav"); 
    SoundPlayer player = new SoundPlayer(s); 
    player.Play(); 
}


method 2:

SoundPlayer sPlayer = new SoundPlayer(chrome32.Properties.Resources.a);
            sPlayer.Play();

chrome32 is assemblyname

8 Kasım 2016 Salı

c# müzik çaldırma

  1. Open "Solution Explorer" from menu toolbar ("VIEW") or simply press Ctrl+Alt+L.
  2. Click on drop-down list of "Properties".
  3. Then select "Resource.resx" and press enter.
open project resource
  1. Now select "Audio" from the combobox list.
add audio files to resource
  1. Then click on "Add Resource", choose audio files (.wav) and click "Open".
browsing for audio files
  1. Select audio file(s) and change "Persistence" properties to "Embedded in .resx".
embedding audio files to resource
b) Now, just write this code to play the audio.
In this code I'm playing audio on form load event.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Media; // at first you've to import this package to access SoundPlayer

namespace WindowsFormsApplication1
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
        }

        private void login_Load(object sender, EventArgs e)
        {
            playaudio(); // calling the function
        }

        private void playaudio() // defining the function
        {
            SoundPlayer audio = new SoundPlayer(WindowsFormsApplication1.Properties.Resources.Connect); // here WindowsFormsApplication1 is the namespace and Connect is the audio file name
            audio.Play();
        }
    }
}
That's it.
All done, now run the project (press f5) and enjoy your sound.
All the best. :)