2
OS : Windows 10
Browser : Firefox 61
Selenium Version 3.13

Code : 
package PhpTravelsPackage;

//import java.awt.List;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByClassName;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.WebElement;

public class phpTravels  {
    public static void main (String args[]) {

        System.setProperty("webdriver.gecko.driver","C:\\\\Marionette\\geckodriver.exe");
        FirefoxOptions options = new FirefoxOptions();
        options.setLogLevel(FirefoxDriverLogLevel.DEBUG);
        WebDriver driver = new FirefoxDriver(options);
        driver.get ("https://www.phptravels.net/");

        WebElement link = null;
        int linksCount = 0 ;

        Actions actions = new Actions(driver);
        actions.moveToElement(driver.findElement(By.id("li_myaccount"))).perform();

    }

}

Error :

 (Program successfully opens the website, but does not perform the action instructed)   
    Exception in thread "main" org.openqa.selenium.WebDriverException: TypeError: rect is undefined
    Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:14.902Z'
    System info: host: 'ADMIN-PC', ip: '192.168.1.7', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_181'
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 61.0.1, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 9652, moz:profile: C:\Users\admin\AppData\Loca..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: XP, platformName: XP, platformVersion: 10.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
    Session ID: a8b8b5b6-d384-4c35-80f6-9d32bdaa428c
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
        at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:614)
        at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:638)
        at org.openqa.selenium.interactions.Actions.perform(Actions.java:594)
        at PhpTravelsPackage.phpTravels.main(phpTravels.java:30)
2
  • 1
    try to get your element by XPath Commented Jul 29, 2018 at 12:21
  • What do you want to do after opening the website ? Commented Jul 29, 2018 at 12:27

1 Answer 1

2

If you want to click on My account button after opening the URL, Then you can try this code:

Note that this id li_myaccount is not unique. There are two web element present in DOM.

WebElement myAccount = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[@id='collapse']/descendant::ul[3]/li[@id='li_myaccount']/a")));
myAccount.click(); 
Sign up to request clarification or add additional context in comments.

1 Comment

Ultimately, i have to click on the My Account button, thanks, this code works well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.