I'm getting the below error while page transition, by clicking on submit button. It looks like there was an issue with the newest Chrome release. Without the disable-gpu Chromeoption set, the renderer will occasionally timeout. The workaround until Google fixes this (if they do fix it at all) is to add the --disable-gpu attribute to the ChromeOptions.
Error-message:
Launching the chrome driver
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8737
Only local connections are allowed.
Aug 22, 2018 10:02:06 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[1534912350.875][SEVERE]: Timed out receiving message from renderer: 20.000
[1534912350.881][SEVERE]: Timed out receiving message from renderer: -0.010
iiiiiiiiiiiiiiiiiii
[1534912370.909][SEVERE]: Timed out receiving message from renderer: 20.000
[1534912370.909][SEVERE]: Timed out receiving message from renderer: -0.001
Exception in thread "main" org.openqa.selenium.TimeoutException: timeout
(Session info: chrome=68.0.3440.106)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'LAPTOP-B3DIN1KF', ip: '192.168.43.235', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_161'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.41.578737 (49da6702b16031..., userDataDir: C:\Users\ACER-S~1\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49380}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 68.0.3440.106, webStorageEnabled: true}
Session ID: b3de58666d2ca24706dc70a9d78094e4
*** Element info: {Using=css selector, value=body > div > div > div > h1 > a}
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.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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.findElement(RemoteWebDriver.java:322)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:416)
at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:314)
at demoPackage.Demo.main(Demo.java:102)
Using the script:
package demoPackage;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.codoid.products.exception.FilloException;
/**
* #author Acer-sumit
*
*/
public class Demo {
public static WebDriver driver = null;
public static JavascriptExecutor js;
public static void main(String args[]) throws FilloException, InterruptedException {
System.out.println("Launching the chrome driver ");
// Set the chrome driver exe file path
System.setProperty("webdriver.chrome.driver","E:\\selenium_sumit\\chromedriver_win32_2.40\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-gpu");
options.addArguments("--disable-browser-side-navigation");
// Instantiate the chrome driver
driver = new ChromeDriver(options);
///System.setProperty("webdriver.edge.driver","E:\\MicrosoftWebDriver.exe");
//driver = new EdgeDriver();
//driver.manage().timeouts().implicitlyWait(6000, TimeUnit.MILLISECONDS);
driver.manage().timeouts().pageLoadTimeout(20,TimeUnit.SECONDS);
//driver.manage().timeouts().setScriptTimeout(60, TimeUnit.SECONDS);
// set the browser URL in get() to load the webpage
try {
driver.navigate().to("https://diggza.com/");
driver.findElement(By.cssSelector("input[name='url']")).clear();
driver.findElement(By.cssSelector("input[name='url']")).sendKeys("https://www.google.com/");
driver.findElement(By.cssSelector("input[name='email']")).sendKeys("sdsjsnssk#gmail.com");
driver.findElement(By.cssSelector("#myform > p:nth-child(5) > a:nth-child(1)")).click();
//wait for element to be visible and perform click
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='submit']")));
js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", driver.findElement(By.cssSelector("input[type='submit']")));
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("iiiiiiiiiiiiiiiiiii");
driver.findElement(By.cssSelector("body > div > div > div > h1 > a")).click();
//driver.navigate().refresh();
}
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("-------fffffffffff---------");
driver.get("https://diggza.com/");
driver.findElement(By.cssSelector("input[name='url']")).clear();
driver.findElement(By.cssSelector("input[name='url']")).sendKeys("https://www.google.com/");
driver.findElement(By.cssSelector("input[name='email']")).sendKeys("sumit.pradhan96#gmail.com");
driver.findElement(By.cssSelector("#myform > p:nth-child(5) > a:nth-child(1)")).click();
//wait for element to be visible and perform click
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='submit']")));
driver.findElement(By.cssSelector("input[type='submit']")).click();
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}
Related
I have a Java program using Selenium and would like to use #FindBy(), but I can't solve the problem. My program is composed of several lines. I would like to share tasks between classes. And for that, I started with identity verification. I created this class which includes login and password.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;
public class LoginPageNew {
WebDriver webDriver;
public LoginPageNew(WebDriver driver) {
this.webDriver = driver;
}
#FindBy(css = "[name='username']")
#CacheLookup
WebElement username;
#FindBy(how = How.NAME, using = "password")
#CacheLookup
WebElement password;
#FindBy(how = How.XPATH, using = "//button[normalize-space()='Login']")
#CacheLookup
WebElement submit_btn;
public void loginPage() {
username.sendKeys("Admin");
password.sendKeys("admin123");
submit_btn.click();
}
}
And I created this class
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class BrowserFactory {
static WebDriver driver;
public static WebDriver startBrowser(String browserName, String url) {
if (browserName.equals("chrome")) {
driver = new ChromeDriver();
}
driver.manage().window().maximize();
driver.get(url);
return driver;
}
}
And finally this test class
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;
public class VerifyLoginPage {
#Test
public void checkValidUser() {
WebDriver webDriver = BrowserFactory.startBrowser("chrome", "http://opensource-demo.orangehrmlive.com/");
LoginPageNew pageNew = PageFactory.initElements(webDriver, LoginPageNew.class);
pageNew.loginPage();
}
}
For me, I would like to work with the site "https://opensource-demo.orangehrmlive.com/" with login and password "Admin" and "admin123" with this architecture to do the test.
And I used
#FindBy(name="username"), #FindBy(css = "[name='username']"),
#Find By(xpath = "//input[#placeholder='Username']")
#Find By(xpath = "(//input[#placeholder='Username'])[1]")
#Find By(how = How. NAME, using = "username")...
But there is no solution, always the same error.
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"[name='username']"}
(Session info: chrome=109.0.5414.76)
For documentation on this error, please visit: https://selenium.dev/exceptions/#no_such_element
Build info: version: '4.7.2', revision: '4d4020c3b7'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [f3cd14b65540143dd77567fdbdd70945, findElement {using=css selector, value=
[name='username']}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 109.0.5414.76,
chrome: {chromedriverVersion: 109.0.5414.74 (e7c5703604da..., userDataDir:
C:\Users\hp\AppData\Local\T...}, goog:chromeOptions: {debuggerAddress: localhost:64620},
networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy:
Proxy(), se:cdp: ws://localhost:64620/devtoo..., se:cdpVersion: 109.0.5414.76, setWindowRect:
true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script:
30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true,
webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
I will add this code
webDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
thank you BMW83
Code Trail
WebElement parentTextBox = driver.findElement(By.id("name"));
parentTextBox.sendKeys("This is parent textbox");
WebElement newWindowBtn = driver.findElement(By.id("newWindowBtn"));
newWindowBtn.click();
String parentWindow = driver.getWindowHandle();
Set<String> getWindows = driver.getWindowHandles();
for (String handles : getWindows) {
if (!handles.equals(parentWindow))
{
driver.switchTo().window(handles);
driver.manage().window().maximize();
WebElement firstName = driver.findElement(By.id("firstName"));
firstName.sendKeys("Pankaj");
}
Thread.sleep(10000);
//driver.switchTo().window(parentWindow);
//driver.switchTo().window("");
driver.switchTo().defaultContent();
Thread.sleep(5000);
parentTextBox.clear();
parentTextBox.sendKeys("switching back to parent window is success");
Error
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=105.0.5195.126)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-9GE1TC7', ip: '192.168.1.6', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 105.0.5195.126, chrome: {chromedriverVersion: 105.0.5195.52 (412c95e51883..., userDataDir: C:\Users\Admin\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:65092}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 2b22a0d3f499205579e31a39c1233d25
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
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:552)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.clear(RemoteWebElement.java:124)
at switchWindows.SwitchWindows.main(SwitchWindows.java:58)
I was trying to run this on the Android TV i see the Appium is able to click on all the buttons and input the data in text box except the very first one. i have to click on it then wait and used send keys to see if it solves the issue but no luck. can someone help me on this.enter image description here
Base.Java
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
public class Base {
public static AndroidDriver<AndroidElement> capabalities() throws MalformedURLException {
File file = new File ("src");
File fs = new File(file,"TVTestApp_ct.apk");
DesiredCapabilities capabalities = new DesiredCapabilities();
capabalities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"uiautomator2");
capabalities.setCapability(MobileCapabilityType.DEVICE_NAME, "Automation");
capabalities.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://127.0.0.1:4723/wd/hub"),capabalities);
return driver;
}
}
HomeScreen.Java
import java.net.MalformedURLException;
import org.openqa.selenium.By;
import org.openqa.selenium.By.ByClassName;
import org.openqa.selenium.StaleElementReferenceException;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class HomeScreen extends Base {
public static void main(String[] args) throws MalformedURLException, InterruptedException {
AndroidDriver<AndroidElement> driver = capabalities();
driver.findElementById("com.tvexample.tvtestapp:id/editText").sendKeys("1234");
driver.findElementById("com.tvexample.tvtestapp:id/editText1").sendKeys("1234")
}
}
Logs:
Jun 21, 2021 2:11:47 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: androidx.test.uiautomator.StaleObjectException
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'TXCDTL20CT1696', ip: '135.70.71.74', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: C:\Users\cg517n\Documents\e..., appPackage: com.tvexample.tvtestapp, automationName: uiautomator2, databaseEnabled: false, desired: {app: C:\Users\cg517n\Documents\e..., automationName: uiautomator2, deviceName: Automation, platformName: android}, deviceApiLevel: 28, deviceManufacturer: unknown, deviceModel: sdk_google_atv_x86, deviceName: emulator-5554, deviceScreenDensity: 320, deviceScreenSize: 1920x1080, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, pixelRatio: 2, platform: LINUX, platformName: Android, platformVersion: 9, statBarHeight: 0, takesScreenshot: true, viewportRect: {height: 1080, left: 0, top: 0, width: 1920}, warnings: {}, webStorageEnabled: false}
Session ID: 75f6f7db-21e8-407e-8a53-59271e4e9e02
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
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 io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)
at io.appium.java_client.DefaultGenericMobileElement.execute(DefaultGenericMobileElement.java:45)
at io.appium.java_client.MobileElement.execute(MobileElement.java:1)
at io.appium.java_client.android.AndroidElement.execute(AndroidElement.java:1)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)
at HomeScreen.main(HomeScreen.java:18)
My code:
System.setProperty("webdriver.chrome.driver", "F:\\Eclipse1\\Selenium\\SeleniumBasic\\lib\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.goibibo.com/flights/");
driver.manage().window().maximize();
Thread.sleep(1000);
System.out.println(driver.getTitle());
driver.findElement(By.xpath("//span[text()='Round trip']")).click();
Thread.sleep(1000);
driver.findElement(By.xpath("//input[#id='gosuggest_inputSrc']")).sendKeys("Coimbatore");
Thread.sleep(1500);
driver.findElement(By.xpath("//ul[#id='react-autosuggest-1']/li[1]")).click();
//or8
//driver.findElement(By.xpath("//ul[#id='react-autosuggest-1']/li[#id='react-autosuggest-1-suggestion--0']")).click();
driver.findElement(By.xpath("//input[#id='gosuggest_inputDest']")).sendKeys("Bangalore");
Thread.sleep(1000);
driver.findElement(By.xpath("//ul[#id='react-autosuggest-1']/li[1]")).click();
driver.findElement(By.xpath("//input[#class='inputSrch curPointFlt ' and #placeholder='Departure']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//div[#class='DayPicker-Day' and #aria-label='Mon Feb 25 2019']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("//div[#class='DayPicker-Day' and #aria-label='Thu Feb 28 2019']")).click();
driver.findElement(By.xpath("//div[#class='dF whiteBg fl col-sm-5 justifyBetween ht45 alignItemsCenter brdrTpBtmRt curPointFlt width20']")).click();
Thread.sleep(1000);
for(int i=0;i<2;i++) {
driver.findElement(By.xpath("//button[#class='fl plusSpin brdrTpBtmRt' and #id='adultPaxPlus']")).click();
}
Select s=new Select(driver.findElement(By.xpath("//select[#class='custSelect width100 whiteBg padTB5 padLR10']")));
s.selectByValue("B");
driver.findElement(By.xpath("//button[#value='Search']")).click();
Thread.sleep(3000);
driver.findElement(By.xpath("//a[#href='javascript:void(0);' and #id='sortByPriceOnw']")).click();
driver.findElement(By.xpath("//i[#class='fl posAbs icon-close1 ico17 curPoint fb whiteBg closePers black']")).click();
System.out.println("hi");
Thread.sleep(1500);
driver.findElement(By.xpath("//a[#href='javascript:void(0);' and #id='sortByPriceRet']")).click();
/*Thread.sleep(1000);
driver.findElement(By.xpath("//i[#class='we_close']")).click();*/
Thread.sleep(1000);
driver.findElement(By.xpath("(//div[#class='control__indicator'])[2]")).click();
Exception:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (648, 603). Other element would receive the click:
(Session info: chrome=72.0.3626.119)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'SAISHANMUKHAVAR', ip: '192.168.137.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.44.609538 (b655c5a60b0b54..., userDataDir: C:\Users\gsais\AppData\Loca...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:60971}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 72.0.3626.119, webStorageEnabled: true}
Session ID: 8279839ce42d641ca8e2c7bdefc6ab07
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at GoIbiboCLass.main(GoIbiboCLass.java:70)
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)
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();