samedi 14 avril 2018

why i using the Type.GetField() aways return null?

i using the GetField() get to selenium the PID,But when i try get "ProcessId" it aways return the null,can see the img,ProcessId field is Not empty. Here's my Code:

public void tes(ChromeDriver driver) {
            var flag = System.Reflection.BindingFlags.NonPublic
                          | System.Reflection.BindingFlags.Instance;
            var executorField = typeof(OpenQA.Selenium.Remote.RemoteWebDriver)
                .GetField("executor",
                          System.Reflection.BindingFlags.NonPublic
                          | System.Reflection.BindingFlags.Instance);
            object executor = executorField.GetValue(driver);
            var Service = executor.GetType().GetField("service", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            object remoteServerPidField = Service.GetValue(executor);
            var pid = remoteServerPidField.GetType().GetField("ProcessId", BindingFlags.Instance | BindingFlags.Static);
        }

enter image description here





Aucun commentaire:

Enregistrer un commentaire