ariya / phantomjs

Scriptable Headless Browser
http://phantomjs.org
BSD 3-Clause "New" or "Revised" License
29.46k stars 5.76k forks source link

PhantomJS 2.1.1 and 2.0.0 can not press button and checkbox, on specific web page #14415

Closed EtherName closed 4 years ago

EtherName commented 8 years ago
  1. Which version of PhantomJS are you using? Tip: run phantomjs --version. 2.0.0 and 2.1.1
  2. What steps will reproduce the problem?
    1. PhantomJSDriver sees this form and the elements on it, can enter a value, but can not press buttons. He shakes them because exception does not throw, but the page does not change. tested this case on FirefoxDriver, logic code is not changed, everything is fine presses.
  3. Which operating system are you using? Windows 10
  4. Did you use binary PhantomJS or did you compile it from source? binary
  5. Please provide any additional information below. Control is - Driver.FindElement(By.XPath(".//form[@id='BetSlipForm']//li[@class='betslipHeader']/a")).Enabled true Driver.FindElement(By.XPath(".//form[@id='BetSlipForm']//li[@class='betslipHeader']/a")).Displayed true PhantomJS settings javascriptEnabled = true or false - does not affect
var driverService = PhantomJSDriverService.CreateDefaultService();
            driverService.HideCommandPromptWindow = true;
            driverService.SslProtocol = "any";
            driverService.IgnoreSslErrors = true;

var configOptions = new PhantomJSOptions();
            configOptions.AddAdditionalCapability("phantomjs.page.settings.loadImages", true);
            configOptions.AddAdditionalCapability("takesScreenshot", false);
            //configOptions.AddAdditionalCapability("elementScrollBehavior", 1);
            if (_webRequestInfo != null && !string.IsNullOrWhiteSpace(_webRequestInfo.UserAgent))
                configOptions.AddAdditionalCapability("phantomjs.page.settings.userAgent", _webRequestInfo.UserAgent);

IWebDriver Driver = new PhantomJSDriver(driverService, configOptions);
            Driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);

I tried to press the buttons in different ways

private IWebElement GetElement(string xPath) {
            try {
                return Driver.FindElement(By.XPath(xPath));
            }
            catch (Exception e) {
                throw new PageScanException(string.Format("The PhantomWebDriver couldn't find element. {0}", e.Message), xPath);
            }
}

public bool Click(string xPath, Func<bool> callbackAfterClick) {
            GetElement(xPath).Click();
            return callbackAfterClick.Invoke();
}
public bool ClickViaScript(string xPath, Func<bool> callbackAfterClick) {
                var element = GetElement(xPath);
                ((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].click()", element);
                return callbackAfterClick.Invoke();
}
 public void FocusView(string xPath) {
                var element = GetElement(xPath);
                var action = new Actions(Driver);
                action.Click(element).Perform();
}

On FirefoxDriver, all pressed bool Click(string xPath, Func<bool> callbackAfterClick); Maybe this is a stupid question, but I have not found an answer, in any forum. If this matter is not your competence, advise where to go. Screenshots will not be added as they are identical before and after pressing. Problem page is Horse racing betslip form on https://mobile.bet365.com/. Thank you in advance.

EtherName commented 8 years ago

Also, there is a problem with the touch of any control on this Betfred mobile site. Also try different settings and different ways PhantomJS clicks - the usual, with the script and that's how

public bool FocusView(string xPath) {
     var element = GetElement (xPath);
     var action = new Actions (Driver);
     action.MoveToElement (element, 2, 2) .Click () Perform ();
     return true;
}

I tried to use mobile useragent, but nothing has changed. The problem is the same. PhantomJS sees everything and it all available, but can not click anything. Operating System and version PhantomJS same. Thank you.

EtherName commented 8 years ago

Also, there is a problem with the main site Betfred. PhantomJS not load the main page frame. <iframe id="sportframe" src='http://warp.betfred.com/UK/2/inplaysc?ver=19' width='820' height='1024' frameborder="0" scrolling="no" allowtransparency="true"></iframe> The settings here are

var driverService = PhantomJSDriverService.CreateDefaultService();
            driverService.HideCommandPromptWindow = true;
            driverService.SslProtocol = "any";
            driverService.IgnoreSslErrors = true;

var configOptions = new PhantomJSOptions();
            configOptions.AddAdditionalCapability("phantomjs.page.settings.loadImages", true);
            configOptions.AddAdditionalCapability("phantomjs.page.settings.loadPlugins", true);
            configOptions.AddAdditionalCapability("takesScreenshot", false);
            configOptions.AddAdditionalCapability("javascriptEnabled", true);
            //configOptions.AddAdditionalCapability("elementScrollBehavior", 1);
            if (_webRequestInfo != null && !string.IsNullOrWhiteSpace(_webRequestInfo.UserAgent))
                configOptions.AddAdditionalCapability("phantomjs.page.settings.userAgent", _webRequestInfo.UserAgent);

IWebDriver Driver = new PhantomJSDriver(driverService, configOptions);
            Driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);

Tried to change them, but no results. Operating System and version PhantomJS same. Or is it better to create new issues for this problem?

stale[bot] commented 4 years ago

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!