How to login to a webpage and get its html code with Java, when it uses post method for logging in?
Date : March 29 2020, 07:55 AM
|
Link to Webpage using Post Method
Date : March 29 2020, 07:55 AM
hop of those help? Ok so i just realized my mistake,really a silly one. in the link to Register Form page in My Login Form Page i didnt add the extension ".html" so tomcat was trying to find a Servlet name Register rather than a link to Register.html
|
Navigation through link list massive in Selenium + Java
Tag : java , By : Willem van Schevikho
Date : March 29 2020, 07:55 AM
seems to work fine I have discovered that when I update webpage the consequences of profile links is breaking down. So, the decision was to open profile link in new window. Do some action and close it. As guys above said using two loops was stupid decision. This code works for me perfect: for(WebElement link : driver.findElements(By.xpath("//img[@alt='Online Now!']/../..//a"))){
String originalWindow =driver.getWindowHandle();
System.out.println("Original handle is: "+ originalWindow);
//open link in new window
act.contextClick(link).perform();
act.sendKeys("w").perform();
Thread.sleep(4000);
for (String newWindow : driver.getWindowHandles())
{
driver.switchTo().window(newWindow);
System.out.println("NOW THE CURRENT Handle is: "+ newWindow);
}
Thread.sleep(2000);
//here write a message
driver.close();
driver.switchTo().window(originalWindow);
}
List<WebElement> allLinks = driver.findElements(By.xpath("//img[@alt='Online Now!']/../..//a"));
//have found links of all online profiles
System.out.println(allLinks.size());
for (WebElement link : allLinks)
{
String originalWindow =driver.getWindowHandle();
System.out.println("Original handle is: "+ originalWindow);
//open link in new window
act.contextClick(link).perform();
act.sendKeys("w").perform();
Thread.sleep(4000);
//continue handling new window
|
Can't click random link again after navigating back to same page - selenium automation
Tag : java , By : Doc Immortal
Date : March 29 2020, 07:55 AM
wish of those help When you navigate to another page (or even refresh the current page) the previously located elements become stale, so you get StaleElementReferenceException. You need to relocate the links driver.navigate().back();
links = driver.findElements(By.cssSelector("#amshopby-page-container > div.category-products > div.products > ul > li > div > h2 > a"));
|
How to get buttons of all forms on webpage using python selenium?
Date : March 29 2020, 07:55 AM
|