Selenium: Unable to locate email type box, not within any iframe - selenium

I am trying to detect the login id and password field of a website : https://mretailstore.com/login but seems selenium is not able to locate the email type box. I have checked stackoverflow but didn't get any solution to this. Someone has used iframe because of what he/she was facing the same issue but here we have not incorporated any iframe.
The error I am getting is:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: .//*[#id='identity']
The code I am using:
System.setProperty("webdriver.gecko.driver", "C:\\Users\\MI SERVICE\\Downloads\\geckodriver.exe");
FirefoxOptions capa = new FirefoxOptions();
capa.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capa);
driver.get("https://www.mretailstore.com/");
driver.findElement(By.xpath(".//*[#id='identity']")).sendKeys("abc#d.com");
driver.findElement(By.xpath(".//*[#id='password']")).sendKeys("abc123");
driver.findElement(By.id("loginbutton")).click();
driver.navigate().back();
driver.close();

It looks your xpath is correct only and this exception is happening before element rendering.So, Please add the some explicit wait after the page loading.
It is working for me with/without Explicit Wait.
Code:
driver.get("https://www.mretailstore.com/");
WebDriverWait wait=new WebDriverWait(driver,20);
wait.until(ExpectedConditions.titleIs("Login"));
driver.findElement(By.xpath(".//*[#id='identity']")).sendKeys("abc#d.com");
driver.findElement(By.xpath(".//*[#id='password']")).sendKeys("abc123");
driver.findElement(By.id("loginbutton")).click();

Related

Link Click using selenium webdriver is giving timeout error, link is working fine on browser otherwise

I'm trying to write a piece of code using Testng in selenium, the problem is when i try to click a link, the code becomes unresponsive and gives error- Timed out receiving message from renderer
Tried driver.get("https://infostore.saiglobal.com/") instead of driver.findElement(By.linkText("Infostore")).click(); still remains unresponsive - Doesnot get directed to the webpage - https://infostore.saiglobal.com/
#Test
public void testSai() throws Exception {
driver.get("https://www.saiglobal.com/"); //open homepage
driver.findElement(By.id("CybotCookiebotDialogBodyButtonAccept")).click(); //accept cookie
driver.findElement(By.cssSelector("#sai-header > div > div.main-nav > div.store-box > div")).click(); //click on Login to open list
sleep(2);
driver.findElement(By.linkText("Infostore")).click(); //click on infostore to be redirected to https://infostore.saiglobal.com/
System.out.println(driver.getCurrentUrl());
Yes I have checked this issue and there is an workaround for this issue if you wish to have this.Try following code.
Take the href attribute value from the link element.
Delete all cookies.
driver.navigate().to(URL);
public static void main(String[] args){
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + File.separator + "\\Executables\\Chromedriver.exe");
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 5);
Actions actions = new Actions(driver);
driver.get("https://www.saiglobal.com/");
driver.findElement(By.id("CybotCookiebotDialogBodyButtonAccept")).click();
WebElement element=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[#class='desktop-login']")));
actions.moveToElement(element).build().perform();
WebElement element1=wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[#class='desktop-login']/ul/li/a[contains(text(),'Infostore')]")));
String str1=element1.getAttribute("href");
driver.manage().deleteAllCookies();
driver.navigate().to(str1);
System.out.println(driver.getCurrentUrl());
}
This seems to be an error with Selenium that the developers have been dealing with for over a year. They never really give a concrete answer as to what causes it or how to fix it.
The first port of call would be to make sure that your browser and Selenium are compatible. Try opening a different URL that you know works, and if the error persists then there is likely an error with the compatibility of your selenium and web browser. If it works, then there is something wrong with your website.
For reference, I opened your website using Python Selenium, and had no issues loading or interacting with elements. So the error is local to the software you are using.
The issue can also be caused by sleeps(no idea why), so try removing any sleeps and see if this stops the issue.

Select a date from Jquery, date picker using selenium webdriver

Go to the Official Website of Jquery https://jqueryui.com/datepicker/
It's not allow be to click on input text even it's have unique id="datepicker" getting an error element not found Exception but when i runs locally by adding jquery date picker it works likes a charm. can somebody help me can't able to figure it out!
2) By using this url i can select anything but it not works with jquery official site as i mentioned above https://jqueryui.com/resources/demos/datepicker/default.html
Below is my actual code that is not getting work
System.setProperty("webdriver.chrome.driver","C:\\ProgramFiles\\chromedriver.exe");
driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://jqueryui.com/datepicker/");
Thread.sleep(5000);
driver.findElement(By.id("datepicker")).click();
The element with id="datepicker" is within a frame. So we have to switch to the intended frame first, then locate the element and then call the click() method as follows:
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://jqueryui.com/datepicker/");
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[#class='demo-frame'][#src='/resources/demos/datepicker/default.html']")));
driver.findElement(By.id("datepicker")).click();
System.out.println("Datepicker Clicked");

Getting 500 error page on logout by Selenium Webdriver script

Updated with code
driver.get("https://stage.ab.org/");
System.out.println(driver.getTitle());
System.out.println(driver.getPageSource());
driver.findElement(By.id("txt-username")).sendKeys("Username");
driver.findElement(By.id("pwd-password")).sendKeys("Passw0rd");
driver.findElement(By.id("login-widget-submit")).click();
Thread.sleep(2000);
driver.findElement(By.cssSelector(".username-link-container")).click();
Thread.sleep(8000);
WebDriverWait wait = new WebDriverWait(driver, 9);
WebElement link = wait.until(ExpectedConditions.elementToBeClickable(By.id("alinkSignOut")));
link.click();
I do not get any errors in Eclipse.
When the Webdriver script runs (logging out a user) it gives 500 Error page. When I do it manually, I am able to it successfully. What is going on with Selenium?
Some issues with VPN, working fine now

Selenium NoSuchElementException with InternetExplorerDriver

I'm doing some R&D with Selenium and I've found an inconsistancy I can't explain between the InternetExplorerDriver and the ChromeDriver.
I run this code:
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.google.com");
var query = driver.FindElement(By.Name("q"));
query.SendKeys("Hello World!");
query.Submit();
Everything works fine, my browser navigates to google and searches for "Hello World!".
But when I try exactly the same code with the InternetExplorerDriver
var driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.com");
var query = driver.FindElement(By.Name("q"));
query.SendKeys("Hello World!");
query.Submit();
I get an error on the FindElement line.
An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred
in WebDriver.dll but was not handled in user code
Additional information: Unable to find element on closed window
I have IE 11.0.9600.17905 installed.
Am I missing a step with IE?
Check out the required configuration section on the IEDriver wiki. I would hazard a guess and say your problem is "you must set the Protected Mode settings for each zone to be the same value".

Selenium Webdriver - Issue while opening the specified url using driver.get()

The Url "http://localhost:8080/Login.aspx" is getting opened as "http://www.localhost.com:8080/Login.aspx" in firefox/chrome, the error page displays "The connection was reset The connection to the server was reset while the page was loading". How to avoid the www.**.com issue?
I tried searching for a solution in google, but coudln't get out of this issue.
Code Sample:
`BeforeClass
public void Setup(){
driver = new FirefoxDriver();
driver.get("http://localhost:8080/Login.aspx");
driver.manage().window().maximize();
}`
try the same thing in IDE with the open command and check if it works...if it does just export the code and use it.
Hope it works.