I was searching quite a lot for finding a solution for my problem and tried a lot with related solutions but they all don´t work for me so i guess i´m missing smth. and would be glad if someone would help me out. So maybe my code first:
package Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.server.handler.FindElement;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class oeffnen {
WebDriver driver;
public static void main(String[] args) throws FileNotFoundException {
System.setProperty("webdriver.gecko.driver", "C:\\\\Program Files\\Java\\jdk-11.0.2\\bin\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.bet365.com/#/IP/");
driver.findElement(By.className("lpdgl")).click();
driver.get("https://www.bet365.com/#/IP/");
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
String value = driver.findElement(By.cssSelector("div.ipo-Competition:nth-child(1) > div:nth-child(3) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > span:nth-child(2)")).getText();
PrintWriter writer = new PrintWriter("D:\\Test.txt");
writer.println(value);
writer.close();
}
private static void WebDriverWait() {
// TODO Auto-generated method stub
}
}
So i´m trying to get the rate that a certain team wins game. Tried several ways of by.xpath and .getText() and ended up now with by.cssselector and still getting no value in my Test.txt. Or just isn´t it possible at this page (blocked)?
I would be really glad if someone could help me here.
Page: https://www.bet365.com/#/IP/
In regards
edit 13.03.2019
here is the html code of that page:
<div>
<div class="wc-WebConsoleModule ">
<div>
<div class="hm-HeaderModule ">
<div class="hm-HeaderModule_Primary ">
<div class="hm-BigButtons hm-BigButtons-noscrollernative "><nav class="hm-BigButtons_Inner "><a class="hm-BigButton ">Sport</a><a class="hm-BigButton hm-BigButton_Highlight ">Live</a><a class="hm-BigButton ">Casino</a><a class="hm-BigButton ">Live-Casino</a><a class="hm-BigButton ">Spiele</a><a class="hm-BigButton ">Poker</a><a class="hm-BigButton ">Vegas</a></nav></div>
<div class="hm-HeaderModule_UserAdmin ">
<div class="hm-Login ">
<div class="hm-Login_UserNameWrapper "><input class="hm-Login_InputField " type="text" />
<div class="hm-Login_InputText ">Jetzt Anmelden</div>
</div>
<div class="hm-Login_PasswordWrapper "><input class="hm-Login_InputField " type="text" /><input class="hm-Login_InputField Hidden " type="password" /><button class="hm-Login_LoginBtn " tabindex="0">OK</button>
<div class="hm-Login_InputText ">Daten vergessen?</div>
</div>
</div>
</div>
</div>
<div class="hm-HeaderModule_Secondary hm-HeaderModule_Secondary-search ">
<div class="sml-SearchHeader ">
<div class="sml-SearchHeader_SearchIcon "> </div>
<input class="sml-SearchTextInput " type="text" placeholder="Suchen" /></div>
<div class="hm-HeaderModule_Menus ">
<div> </div>
<a class="hm-HeaderModule_Link ">Spielsuchtprävention</a><a class="hm-HeaderModule_Link ">Live-Bilder</a><a class="hm-HeaderModule_Link ">Hilfe</a>
<div>
<div class="hm-LanguageDropDownSelections hm-DropDownSelections "><a class="hm-DropDownSelections_Button hm-DropDownSelections_DropLink ">Sprache<span class="hm-DropDownSelections_Highlight ">Deutsch</span></a></div>
</div>
<div>
<div class="hm-OddsDropDownSelections hm-DropDownSelections "><a class="hm-DropDownSelections_Button hm-DropDownSelections_DropLink ">Quoten<span class="hm-DropDownSelections_Highlight ">Dezimal</span></a></div>
</div>
<div class="hm-ServicesDropDownSelections hm-DropDownSelections "><a class="hm-DropDownSelections_Button hm-DropDownSelections_DropLink hm-DropDownSelections_Solo ">Service</a></div>
</div>
<div class="hm-HeaderModule_TimeLastLogin "><time class="hm-Clock ">20:19:32 CET</time></div>
</div>
</div>
</div>
<div class="wc-PageView ">
<div class="wc-PageView_Main wc-InPlayPage_MainContainer ">
<div>
<div class="ip-InPlayModule ">
<div class="ip-ControlBar ">
<div class="ip-ControlBar_BBarItem wl-ButtonBar_Selected ">Übersicht</div>
<div class="ip-ControlBar_BBarItem ">Einzelanzeige</div>
<div class="ip-ControlBar_BBarItem ">Kalender</div>
</div>
<div class="ipo-OverViewView ">
<div class="ipo-OverViewNativeScroller ipo-OverViewNativeScroller-scrollable ">
<div class="ipo-OverViewNativeScroller_ContentContainer " style="max-height: 424.3333282470703px;">
<div class="ipo-OverViewView_ContentContainer ipo-OverViewNativeScroller_Content ipo-ClassificationBarScrollable_RightArrowVisible ">
<div class="ipo-ClassificationBar ">
<div class="ipo-ClassificationBarScrollable ipo-ClassificationBarScrollable-notransition ">
<div class="ipo-ClassificationBarScrollable_LeftArrow ipo-ClassificationBarScrollable_Hidden "> </div>
<div class="ipo-ClassificationBarScrollable_HScroll">
<div class="ipo-ClassificationBar_ButtonContainer ipo-ClassificationBarScrollable_ScrollContent ipo-ClassificationBarScrollable_ScrollContentNoAnimation ">
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Favoriten</div>
</div>
<div class="ipo-ClassificationBarButtonBase ipo-ClassificationBarButtonBase_Selected ipo-ClassificationBarButtonBase_Selected-1 ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Fußball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Tennis</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Badminton</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Baseball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Basketball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">E-Sports</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Eishockey</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Floorball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Futsal</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Handball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Pferderennen</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Snooker</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Squash</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Tischtennis</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Volleyball</div>
</div>
<div class="ipo-ClassificationBarButtonBase ">
<div class="ipo-ClassificationBarButtonBase_Icon "> </div>
<div class="ipo-ClassificationBarButtonBase_Label ">Windhundrennen</div>
</div>
</div>
</div>
<div class="ipo-ClassificationBarScrollable_RightArrow "> </div>
</div>
</div>
<div class="ipo-OverViewDetail ">
<div class="ipo-OverViewDetail_Container ipo-Classification ">
<div class="ipo-ClassificationHeader_Header ipo-ClassificationHeader_Header-1 ipo-ClassificationHeader_Header-lightgreenborder ipo-ClassificationHeader_Header-moremarkets ">
<div class="ipo-ClassificationHeader_HeaderLabel ">Fußball</div>
<div class="ipo-ClassificationHeader_EventButtonWrapper ">
<div class="ipo-ClassificationHeader_EventButtonInnerWrapper ">
<div class="ipo-ClassificationHeader_EventButton ipo-ClassificationHeader_EventButton-selected ">Alle Events</div>
<div class="ipo-ClassificationHeader_EventButton ">Live-Bilder</div>
</div>
</div>
<div class="ipo-ClassificationHeader_MarketsButtonOuterWrapper ">
<div class="ipo-ClassificationHeader_MarketsButtonWrapper ">
<div class="ipo-ClassificationHeader_MarketsButton ipo-ClassificationHeader_MarketsButton-transparent ">Alle Wettmöglichkeiten</div>
<div class="ipo-ClassificationHeader_MarketsButton ipo-InPlayClassificationMarketSelector ipo-ClassificationHeader_MarketsButton-selected ">
<div class="ipo-InPlayClassificationMarketSelector_DropDown ipo-InPlayClassificationMarketSelectorDropDown ip-DropDownContainer ">
<div class="ipo-InPlayClassificationMarketSelectorDropdownLabelContainer ">
<div class="ip-DropDownContainer_Button ipo-InPlayClassificationMarketSelectorDropDown_Button ipo-InPlayClassificationMarketSelectorDropDown_Button-1 ">Haupt-Wettmöglichkeiten</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ipo-FavouritesContainer "> </div>
<div class="ipo-CompetitionRenderer ">
<div class="ipo-Competition ipo-Competition-open ">
<div class="ipo-CompetitionButton ">
<div class="ipo-CompetitionButton_NameLabel ipo-CompetitionButton_NameLabelHasMarketHeading ">Deutschland - 3. Liga</div>
<div class="ipo-CompetitionButton_MarketHeadingWrapper">
<div class="ipo-CompetitionButton_MarketHeadingLabel ">1X2</div>
<div class="ipo-CompetitionButton_MarketHeadingLabel ">Nächstes Tor</div>
<div class="ipo-CompetitionButton_MarketHeadingLabel ">Tore - Spiel</div>
</div>
</div>
<div class="ipo-Competition_FavouriteWrapper"> </div>
<div class="ipo-FixtureRenderer ipo-Competition_Container ">
<div class="ipo-Fixture ipo-Fixture_CL1 ipo-Fixture-hastimer ipo-Fixture_MainMarkets ">
<div class="ipo-Fixture_TableRow ">
<div class="ipo-Fixture_ScoreDisplay ipo-ScoreDisplayStandard ">
<div class="ipo-ScoreDisplayStandard_Wrapper ">
<div class="ipo-InPlayTimer ">58:27</div>
<div class="ipo-TeamStack ">
<div class="ipo-TeamStack_Team"><span class="ipo-TeamStack_TeamWrapper ">1. FC Kaiserslautern</span>
<div class="ipo-SoccerTeamStack_TeamGoalMarker "><span class="ipo-SoccerTeamStack_TeamGoalMarkerSpan ">TOR</span></div>
</div>
<div class="ipo-TeamStack_Team"><span class="ipo-TeamStack_TeamWrapper ">Eintracht Braunschweig</span>
<div class="ipo-SoccerTeamStack_TeamGoalMarker "><span class="ipo-SoccerTeamStack_TeamGoalMarkerSpan ">TOR</span></div>
</div>
<div class="ipo-TeamStack_Team"><span class="ipo-TeamStack_TeamWrapper ipo-TeamStack_DrawWrapper">Unentschieden</span></div>
</div>
<div class="ipo-TeamPoints ">
<div class="ipo-TeamPoints_TeamScoresWrapper ">
<div class="ipo-TeamPoints_TeamScore ipo-TeamPoints_TeamScore-teamone ">0</div>
<div class="ipo-TeamPoints_TeamScore ipo-TeamPoints_TeamScore-teamtwo ">0</div>
</div>
</div>
<div class="ipo-ScoreDisplayStandard_MediaButton "> </div>
</div>
</div>
<div class="ipo-MainMarkets ">
<div class="ipo-MainMarketRenderer ">
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">1.83</span></div>
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">11.00</span></div>
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">2.30</span></div>
</div>
<div class="ipo-MainMarketRenderer ">
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant ipo-ParticipantNoGoal gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">1.72</span></div>
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant ipo-ParticipantNoGoal gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">6.50</span></div>
<div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant ipo-ParticipantNoGoal gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Name">Kein 1.</span><span class="gl-ParticipantCentered_Odds">2.62</span></div>
</div>
<div class="ipo-MainMarketRenderer ">
<div class="gl-ParticipantCentered ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Handicap">Ü 0.5</span><span class="gl-ParticipantCentered_Odds">1.44</span></div>
<div class="gl-ParticipantCentered ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Handicap">U 0.5</span><span class="gl-ParticipantCentered_Odds">2.62</span></div>
<div class="ipo-MainMarketRenderer_BlankParticipant "> </div>`
I want to get the "1.83" in here <div class="gl-ParticipantCentered gl-ParticipantCentered_NoHandicap ipo-AllMarketsParticipant gl-ParticipantCentered_BlankName "><span class="gl-ParticipantCentered_Odds">1.83</span></div>
edit 13.03.2019
Now i am receiving this message:
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: div.ipo-Competition:nth-child(1) > div:nth-child(3) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > span:nth-child(2)
edit 14.03.2019
Later, if its working to catch the rate, i would like to make a loop to get the rates of all games with x = 1->n "div:nth-child(x)".
edit 16.03.2019
Ok, since i didnt get forward this way i installed the Selenium IDE on Firefox, recorded just a click on a rate on that page.
Thats the result:
"comment": "",
"command": "click",
"target": "css=.ipo-Competition:nth-child(2) .ipo-MainMarketRenderer:nth-child(1) > .gl-ParticipantCentered:nth-child(3) > .gl-ParticipantCentered_Odds",
"targets": [
["css=.ipo-Competition:nth-child(2) .ipo-MainMarketRenderer:nth-child(1) > .gl-ParticipantCentered:nth-child(3) > .gl-ParticipantCentered_Odds", "css:finder"],
["xpath=//div[2]/div[3]/div/div/div[2]/div/div[3]/span[2]", "xpath:position"],
["xpath=//span[contains(.,'5.00')]", "xpath:innerText"]´
So i tried to get these two ways of locators into my script and just make a click to see if he gets it, but still doesnt work:
driver.findElement(By.cssSelector(".ipo-Competition:nth-child(2) .ipo-MainMarketRenderer:nth-child(1) > .gl-ParticipantCentered:nth-child(3) > .gl-ParticipantCentered_Odds")).click();
driver.findElement(By.xpath("//div[2]/div[3]/div/div/div[2]/div[2]/div[2]/span[2]")).click();
Just checking - Are you trying to get the value out of a button element ? I think you may need to try to capture it in a webElement object (org.openqa.selenium.WebElement).
This is a sample from one of my old Cucumber Test cases which pulls the value from a button element.
WebElement okButton = driver.findElement(By.id("confirmOk"));
WebElement cancelButton = driver.findElement(By.id("confirmCancle"));
assertEquals(okButton.getText(),"OK");
assertEquals(cancelButton.getText(),"Cancel");
You can use either By.Id or By.Xpath or By.cssselector but I think you just need that one extra step to capture the value. Not sure if that answers your question.
So the problem is that you are declaring a string value as null and then in the next line doing .getAttribute(value) which is .getAttribute(null) in this case.
String value = null;
driver.findElement(By.cssSelector(...)).getAttribute(value);
My guess is that you want to do something more like the below to get the text. You need to delete the first line, store the return in the value variable so that it will get printed.
// String value = null; <- DELETE THIS LINE
String value = driver.findElement(By.cssSelector(...)).getText();
Related
I meet a problem.
I download Bootstrap design for my project. When I unzip design to package and run a page everything is displayed correctly.
Then I copy html's pages and resources(css, js, images) to my project. Then I refactor index.html to index.ftl and run my project, the index page displayed a wrong view.
I haven't got any errors and warnings in Console and Network(in Chrome).
Freemarker can't displayed page correctly?
MainController.java
#Controller
public class MainController {
#Autowired
CategoryService categoryService;
#RequestMapping("/")
public String home() {
return "redirect:/index";
}
#RequestMapping("/index")
public String showIndex(Model model) {
model.addAttribute("categories", categoryService.getAllMainCategories());
return "index";
}
}
index.html (and .ftl)
<!DOCTYPE html>
<html>
<head>
<title>Grocery Store | Home</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- //for-mobile-apps -->
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- font-awesome icons -->
<link href="css/font-awesome.css" rel="stylesheet" type="text/css" media="all" />
<!-- //font-awesome icons -->
<!-- js -->
<script src="js/jquery-1.11.1.min.js"></script>
<!-- //js -->
<link href='//fonts.googleapis.com/css?family=Ubuntu:400,300,300italic,400italic,500,500italic,700,700italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<!-- start-smoth-scrolling -->
</head>
<body>
<!-- header -->
<div class="agileits_header">
<div class="w3l_offers">
Today's special Offers !
</div>
<div class="w3l_search">
<form action="#" method="post">
<input type="text" name="Product" value="Search a product..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Search a product...';}" required="">
<input type="submit" value=" ">
</form>
</div>
<div class="product_list_header">
<form action="#" method="post" class="last">
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="display" value="1" />
<input type="submit" name="submit" value="View your cart" class="button" />
</fieldset>
</form>
</div>
<div class="w3l_header_right">
<ul>
<li class="dropdown profile_details_drop">
<i class="fa fa-user" aria-hidden="true"></i><span class="caret"></span>
<div class="mega-dropdown-menu">
<div class="w3ls_vegetables">
<ul class="dropdown-menu drp-mnu">
<li>Login</li>
<li>Sign Up</li>
</ul>
</div>
</div>
</li>
</ul>
</div>
<div class="w3l_header_right1">
<h2>Contact Us</h2>
</div>
<div class="clearfix"> </div>
</div>
<!-- script-for sticky-nav -->
<script>
$(document).ready(function() {
var navoffeset=$(".agileits_header").offset().top;
$(window).scroll(function(){
var scrollpos=$(window).scrollTop();
if(scrollpos >=navoffeset){
$(".agileits_header").addClass("fixed");
}else{
$(".agileits_header").removeClass("fixed");
}
});
});
</script>
<!-- //script-for sticky-nav -->
<div class="logo_products">
<div class="container">
<div class="w3ls_logo_products_left">
<h1><span>Grocery</span> Store</h1>
</div>
<div class="w3ls_logo_products_left1">
<ul class="special_items">
<li>Events<i>/</i></li>
<li>About Us<i>/</i></li>
<li>Best Deals<i>/</i></li>
<li>Services</li>
</ul>
</div>
<div class="w3ls_logo_products_left1">
<ul class="phone_email">
<li><i class="fa fa-phone" aria-hidden="true"></i>(+0123) 234 567</li>
<li><i class="fa fa-envelope-o" aria-hidden="true"></i>store#grocery.com</li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //header -->
<!-- banner -->
<div class="banner">
<div class="w3l_banner_nav_left">
<nav class="navbar nav_bottom">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header nav_2">
<button type="button" class="navbar-toggle collapsed navbar-toggle1" data-toggle="collapse" data-target="#bs-megadropdown-tabs">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-megadropdown-tabs">
<ul class="nav navbar-nav nav_1">
<li>Branded Foods</li>
<li>Households</li>
<li class="dropdown mega-dropdown active">
Veggies & Fruits<span class="caret"></span>
<div class="dropdown-menu mega-dropdown-menu w3ls_vegetables_menu">
<div class="w3ls_vegetables">
<ul>
<li>Vegetables</li>
<li>Fruits</li>
</ul>
</div>
</div>
</li>
<li>Kitchen</li>
<li>Short Codes</li>
<li class="dropdown">
Beverages<span class="caret"></span>
<div class="dropdown-menu mega-dropdown-menu w3ls_vegetables_menu">
<div class="w3ls_vegetables">
<ul>
<li>Soft Drinks</li>
<li>Juices</li>
</ul>
</div>
</div>
</li>
<li>Pet Food</li>
<li class="dropdown">
Frozen Foods<span class="caret"></span>
<div class="dropdown-menu mega-dropdown-menu w3ls_vegetables_menu">
<div class="w3ls_vegetables">
<ul>
<li>Frozen Snacks</li>
<li>Frozen Nonveg</li>
</ul>
</div>
</div>
</li>
<li>Bread & Bakery</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>
<div class="w3l_banner_nav_right">
<section class="slider">
<div class="flexslider">
<ul class="slides">
<li>
<div class="w3l_banner_nav_right_banner">
<h3>Make your <span>food</span> with Spicy.</h3>
<div class="more">
Shop now
</div>
</div>
</li>
<li>
<div class="w3l_banner_nav_right_banner1">
<h3>Make your <span>food</span> with Spicy.</h3>
<div class="more">
Shop now
</div>
</div>
</li>
<li>
<div class="w3l_banner_nav_right_banner2">
<h3>upto <i>50%</i> off.</h3>
<div class="more">
Shop now
</div>
</div>
</li>
</ul>
</div>
</section>
<!-- flexSlider -->
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" property="" />
<script defer src="js/jquery.flexslider.js"></script>
<script type="text/javascript">
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
start: function(slider){
$('body').removeClass('loading');
}
});
});
</script>
<!-- //flexSlider -->
</div>
<div class="clearfix"></div>
</div>
<!-- banner -->
<div class="banner_bottom">
<div class="wthree_banner_bottom_left_grid_sub">
</div>
<div class="wthree_banner_bottom_left_grid_sub1">
<div class="col-md-4 wthree_banner_bottom_left">
<div class="wthree_banner_bottom_left_grid">
<img src="images/4.jpg" alt=" " class="img-responsive" />
<div class="wthree_banner_bottom_left_grid_pos">
<h4>Discount Offer <span>25%</span></h4>
</div>
</div>
</div>
<div class="col-md-4 wthree_banner_bottom_left">
<div class="wthree_banner_bottom_left_grid">
<img src="images/5.jpg" alt=" " class="img-responsive" />
<div class="wthree_banner_btm_pos">
<h3>introducing <span>best store</span> for <i>groceries</i></h3>
</div>
</div>
</div>
<div class="col-md-4 wthree_banner_bottom_left">
<div class="wthree_banner_bottom_left_grid">
<img src="images/6.jpg" alt=" " class="img-responsive" />
<div class="wthree_banner_btm_pos1">
<h3>Save <span>Upto</span> $10</h3>
</div>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<!-- top-brands -->
<div class="top-brands">
<div class="container">
<h3>Hot Offers</h3>
<div class="agile_top_brands_grids">
<div class="col-md-3 top_brand_left">
<div class="hover14 column">
<div class="agile_top_brand_left_grid">
<div class="tag"><img src="images/tag.png" alt=" " class="img-responsive" /></div>
<div class="agile_top_brand_left_grid1">
<figure>
<div class="snipcart-item block" >
<div class="snipcart-thumb">
<img title=" " alt=" " src="images/1.png" />
<p>fortune sunflower oil</p>
<h4>$7.99 <span>$10.00</span></h4>
</div>
<div class="snipcart-details top_brand_home_details">
<form action="checkout.html" method="post">
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value=" " />
<input type="hidden" name="item_name" value="Fortune Sunflower Oil" />
<input type="hidden" name="amount" value="7.99" />
<input type="hidden" name="discount_amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value=" " />
<input type="hidden" name="cancel_return" value=" " />
<input type="submit" name="submit" value="Add to cart" class="button" />
</fieldset>
</form>
</div>
</div>
</figure>
</div>
</div>
</div>
</div>
<div class="col-md-3 top_brand_left">
<div class="hover14 column">
<div class="agile_top_brand_left_grid">
<div class="agile_top_brand_left_grid1">
<figure>
<div class="snipcart-item block" >
<div class="snipcart-thumb">
<img title=" " alt=" " src="images/3.png" />
<p>basmati rise (5 Kg)</p>
<h4>$11.99 <span>$15.00</span></h4>
</div>
<div class="snipcart-details top_brand_home_details">
<form action="#" method="post">
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value=" " />
<input type="hidden" name="item_name" value="basmati rise" />
<input type="hidden" name="amount" value="11.99" />
<input type="hidden" name="discount_amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value=" " />
<input type="hidden" name="cancel_return" value=" " />
<input type="submit" name="submit" value="Add to cart" class="button" />
</fieldset>
</form>
</div>
</div>
</figure>
</div>
</div>
</div>
</div>
<div class="col-md-3 top_brand_left">
<div class="hover14 column">
<div class="agile_top_brand_left_grid">
<div class="agile_top_brand_left_grid_pos">
<img src="images/offer.png" alt=" " class="img-responsive" />
</div>
<div class="agile_top_brand_left_grid1">
<figure>
<div class="snipcart-item block">
<div class="snipcart-thumb">
<img src="images/2.png" alt=" " class="img-responsive" />
<p>Pepsi soft drink (2 Ltr)</p>
<h4>$8.00 <span>$10.00</span></h4>
</div>
<div class="snipcart-details top_brand_home_details">
<form action="#" method="post">
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value=" " />
<input type="hidden" name="item_name" value="Pepsi soft drink" />
<input type="hidden" name="amount" value="8.00" />
<input type="hidden" name="discount_amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value=" " />
<input type="hidden" name="cancel_return" value=" " />
<input type="submit" name="submit" value="Add to cart" class="button" />
</fieldset>
</form>
</div>
</div>
</figure>
</div>
</div>
</div>
</div>
<div class="col-md-3 top_brand_left">
<div class="hover14 column">
<div class="agile_top_brand_left_grid">
<div class="agile_top_brand_left_grid_pos">
<img src="images/offer.png" alt=" " class="img-responsive" />
</div>
<div class="agile_top_brand_left_grid1">
<figure>
<div class="snipcart-item block">
<div class="snipcart-thumb">
<img src="images/4.png" alt=" " class="img-responsive" />
<p>dogs food (4 Kg)</p>
<h4>$9.00 <span>$11.00</span></h4>
</div>
<div class="snipcart-details top_brand_home_details">
<form action="#" method="post">
<fieldset>
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="business" value=" " />
<input type="hidden" name="item_name" value="dogs food" />
<input type="hidden" name="amount" value="9.00" />
<input type="hidden" name="discount_amount" value="1.00" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value=" " />
<input type="hidden" name="cancel_return" value=" " />
<input type="submit" name="submit" value="Add to cart" class="button" />
</fieldset>
</form>
</div>
</div>
</figure>
</div>
</div>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- //top-brands -->
<!-- fresh-vegetables -->
<div class="fresh-vegetables">
<div class="container">
<h3>Top Products</h3>
<div class="w3l_fresh_vegetables_grids">
<div class="col-md-3 w3l_fresh_vegetables_grid w3l_fresh_vegetables_grid_left">
<div class="w3l_fresh_vegetables_grid2">
<ul>
<li><i class="fa fa-check" aria-hidden="true"></i>All Brands</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Vegetables</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Fruits</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Juices</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Pet Food</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Bread & Bakery</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Cleaning</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Spices</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Dry Fruits</li>
<li><i class="fa fa-check" aria-hidden="true"></i>Dairy Products</li>
</ul>
</div>
</div>
<div class="col-md-9 w3l_fresh_vegetables_grid_right">
<div class="col-md-4 w3l_fresh_vegetables_grid">
<div class="w3l_fresh_vegetables_grid1">
<img src="images/8.jpg" alt=" " class="img-responsive" />
</div>
</div>
<div class="col-md-4 w3l_fresh_vegetables_grid">
<div class="w3l_fresh_vegetables_grid1">
<div class="w3l_fresh_vegetables_grid1_rel">
<img src="images/7.jpg" alt=" " class="img-responsive" />
<div class="w3l_fresh_vegetables_grid1_rel_pos">
<div class="more m1">
Shop now
</div>
</div>
</div>
</div>
<div class="w3l_fresh_vegetables_grid1_bottom">
<img src="images/10.jpg" alt=" " class="img-responsive" />
<div class="w3l_fresh_vegetables_grid1_bottom_pos">
<h5>Special Offers</h5>
</div>
</div>
</div>
<div class="col-md-4 w3l_fresh_vegetables_grid">
<div class="w3l_fresh_vegetables_grid1">
<img src="images/9.jpg" alt=" " class="img-responsive" />
</div>
<div class="w3l_fresh_vegetables_grid1_bottom">
<img src="images/11.jpg" alt=" " class="img-responsive" />
</div>
</div>
<div class="clearfix"> </div>
<div class="agileinfo_move_text">
<div class="agileinfo_marquee">
<h4>get <span class="blink_me">25% off</span> on first order and also get gift voucher</h4>
</div>
<div class="agileinfo_breaking_news">
<span> </span>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- //fresh-vegetables -->
<!-- newsletter -->
<div class="newsletter">
<div class="container">
<div class="w3agile_newsletter_left">
<h3>sign up for our newsletter</h3>
</div>
<div class="w3agile_newsletter_right">
<form action="#" method="post">
<input type="email" name="Email" value="Email" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email';}" required="">
<input type="submit" value="subscribe now">
</form>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //newsletter -->
<!-- footer -->
<div class="footer">
<div class="container">
<div class="col-md-3 w3_footer_grid">
<h3>information</h3>
<ul class="w3_footer_grid_list">
<li>Events</li>
<li>About Us</li>
<li>Best Deals</li>
<li>Services</li>
<li>Short Codes</li>
</ul>
</div>
<div class="col-md-3 w3_footer_grid">
<h3>policy info</h3>
<ul class="w3_footer_grid_list">
<li>FAQ</li>
<li>privacy policy</li>
<li>terms of use</li>
</ul>
</div>
<div class="col-md-3 w3_footer_grid">
<h3>what in stores</h3>
<ul class="w3_footer_grid_list">
<li>Pet Food</li>
<li>Frozen Snacks</li>
<li>Kitchen</li>
<li>Branded Foods</li>
<li>Households</li>
</ul>
</div>
<div class="col-md-3 w3_footer_grid">
<h3>twitter posts</h3>
<ul class="w3_footer_grid_list1">
<li><label class="fa fa-twitter" aria-hidden="true"></label><i>01 day ago</i><span>Non numquam http://sd.ds/13jklf#
eius modi tempora incidunt ut labore et
http://sd.ds/1389kjklf#quo nulla.</span></li>
<li><label class="fa fa-twitter" aria-hidden="true"></label><i>02 day ago</i><span>Con numquam http://fd.uf/56hfg#
eius modi tempora incidunt ut labore et
http://fd.uf/56hfg#quo nulla.</span></li>
</ul>
</div>
<div class="clearfix"> </div>
<div class="agile_footer_grids">
<div class="col-md-3 w3_footer_grid agile_footer_grids_w3_footer">
<div class="w3_footer_grid_bottom">
<h4>100% secure payments</h4>
<img src="images/card.png" alt=" " class="img-responsive" />
</div>
</div>
<div class="col-md-3 w3_footer_grid agile_footer_grids_w3_footer">
<div class="w3_footer_grid_bottom">
<h5>connect with us</h5>
<ul class="agileits_social_icons">
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-instagram" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
</ul>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="wthree_footer_copy">
<p>© 2016 Grocery Store. All rights reserved | Design by W3layouts</p>
</div>
</div>
</div>
<!-- //footer -->
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$(".dropdown").hover(
function() {
$('.dropdown-menu', this).stop( true, true ).slideDown("fast");
$(this).toggleClass('open');
},
function() {
$('.dropdown-menu', this).stop( true, true ).slideUp("fast");
$(this).toggleClass('open');
}
);
});
</script>
<!-- here stars scrolling icon -->
<script type="text/javascript">
$(document).ready(function() {
/*
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 1200,
easingType: 'linear'
};
*/
$().UItoTop({ easingType: 'easeOutQuart' });
});
</script>
<!-- //here ends scrolling icon -->
<script src="js/minicart.js"></script>
<script>
paypal.minicart.render();
paypal.minicart.cart.on('checkout', function (evt) {
var items = this.items(),
len = items.length,
total = 0,
i;
// Count the number of each item in the cart
for (i = 0; i < len; i++) {
total += items[i].get('quantity');
}
if (total < 3) {
alert('The minimum order quantity is 3. Please add more to your shopping cart before checking out');
evt.preventDefault();
}
});
</script>
</body>
</html>
Images hosting:
link html page view (correct)
https://ibb.co/frTcaw
ling ftl page view (wrong)
https://ibb.co/fLUpoG
project structure:
-web app
-css
-js
-fonts
-images
-WEB-INF
-view
-ftl
index.ftl
Paths to css, fonts and js in ftl page is true.
How can I make a correct view?
I need to locate each item and click on it.
I tired this:
List<WebElement> allTournaments = driver.findElements(By.xpath("//*[#id='main-section']/div/div/section/div[1]/ul/li/div/div[1]/div"));
for (WebElement tournament : allTournaments) {
tournament.click();
}
But got the error "element not visible"
The xpath of first element is //[#id='main-section']/div/div/section/div1/ul/li1/div/div1/div
xpath of second element is //[#id='main-section']/div/div/section/div1/ul/li[2]/div/div1/div
like wise..
can anybody help..?
HTML:
<div class="header-toggle-area">
<div class="header-notification-area text-right ng-scope" ng-controller="notificationController">
</header>
<!--HEADER ENDS-->
<div class="content-wrap" style="padding-top: 60px;">
<aside id="main-sidebar">
<!--MAIN SIDEBAR ENDS-->
<main id="main-section">
<div class="main-content">
<div class="ng-scope" ng-controller="NewTournamentsController as tournaments">
<header class="member-title dt-title-main">
<section class="dashboard-tournaments-listing">
<div class="" ng-show="tournaments.Page==1">
<ul class="row dashboard-listing">
<!-- ngRepeat: running in tournaments.runningTournaments -->
<li class="dashboard-listing-items ng-scope" ng-repeat="running in tournaments.runningTournaments" style="">
<div class="dtslider-block">
<div class="dtslider-content">
<img ng-src="../../category/categoryDefault.jpg" alt="slider" src="../../category/categoryDefault.jpg"/>
<div class="hover-contents">
<div class="hc-timer">
<p> Tournament ends in </p>
<div class="hct-ticker ng-binding"> 04:30 - 26/11/16 </div>
</div>
<div class="hc-details">
<div class="hcd-block ng-hide" ng-show="running.JoinedPlayers>0">
<ul class="hc-icons">
</div>
</div>
</div>
Check if each element is visible and clickable as follows:
for (WebElement tournament : allTournaments) {
if (tournament.isDisplayed()
&& ExpectedConditions.elementToBeClickable(tournament).equals(true)) {
tournament.click();
}
}
I am using Spring MVC, Jquery,Hibernate and tomcat while I am trying to call the save method on controller through ajax and Jquery. while click the save button I am getting this syntactically incorrect error on tomcat here is the code
<script type="text/javascript">
function invokeCancel() {
var a = confirm("are you sure to cancel the page");
if (a == true) {
var urlString = "display.do";
$.ajax({
type : "GET",
url : urlString,
success : function(response) {
$("#addEditViewcontractDetailsDiv").html("");
$("#addEditViewcontractDetailsDiv").hide();
},
error : function() {
alert("Error occured during cancel process");
}
});
} else
return false;
}
$("#piId").focusout(function() {
valaidateElement('piId', 'c1');
});
$("#piName").focusout(function() {
validateElement('piName', 'c2');
});
$("#studyId").focusout(function() {
validateElement('studyId', 'c3');
});
$("#studyName").focusout(function() {
validateElement('studyName', 'c4');
});
$("#contractType").focusout(function() {
validateElement('contractType', 'c5');
});
$("#contractStartDate").focusout(function() {
validateElement('contractStartDate', 'c6');
});
$("#contractEndDate").focusout(function() {
validateElement('contractEndDate', 'c7');
});
$("#paymentTerms").focusout(function() {
validateElement('paymentTerms', 'c8');
});
$("#modeOfPayment").focusout(function() {
validateElement('modeOfPayment', 'c9');
});
$("#panNumber").focusout(function() {
validateElement('panNumber', 'c10');
});
function validateAllElements() {
return valaidateElement('piId', 'c1')
&& validateElement('piName', 'c2')
&& validateElement('studyId', 'c3')
&& validateElement('studyName', 'c4')
&& validateElement('contractType', 'c5')
&& validateElement('contractStartDate', 'c6')
&& validateElement('contractEndDate', 'c7')
&& validateElement('paymentTerms', 'c8')
&& validateElement('modeOfPayment', 'c9')
&& validateElement('panNumber', 'c10');
}
$(document).ready(function() {
for ( var i=1; i<11; i++) {
$("#c" + i).hide();
};
$("#saveBtn").click(function() {
if (validateAllElements()) {
$("#contacrtDetailsPage").submit();
}
});
});
$("#updateBtn").click(function() {
if (validateAllElements()) {
$("#contacrtDetailsPage").attr("action", "updateContract.do");
$("#contacrtDetailsPage").submit();
}
});
$(document)
.ready(
function() {
$("#removeVariable").hide();
var counter = 2;
$("#addVariable")
.click(
function() {
$("#removeVariable").show();
if (counter > 10) {
alert("Only 10 milestones allow");
return false;
}
var newTextBoxDiv = $(
document
.createElement('div'))
.attr(
"id",
'milestoneDiv'
+ counter);
newTextBoxDiv
.after()
.html(
'<div class="row">'
+ '<div class="col-md-12">'
+ '<p class="bx-form"><label> MileStone '
+ counter
+ ' </label>'
+ ' '
+ '<input type="text" size="32" id="mileStone" placeholder="Please Enter Milestone" name="mileStone' + counter +
'" path="mileStone' + counter + '" value="" ></p></div></div>');
newTextBoxDiv
.appendTo("#mileStoneGroup");
counter++;
});
$("#removeVariable").click(function() {
counter--;
$("#milestoneDiv" + counter).remove();
if (counter == 2) {
$("#removeVariable").hide();
alert("No more milestones to remove");
return false;
}
});
});
</script>
</head>
<body>
<sf:form id="contacrtDetailsPage" page="contacrtDetailsPage"
modelAttribute="contractDetails" method="post"
action="saveContract.do">
<div class="mx-main">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">
Contract Details >>
<c:choose>
<c:when test='${ACTION_TYPE == "EDIT"}'>
Update
</c:when>
<c:otherwise>
Create
</c:otherwise>
</c:choose>
</h3>
</div>
<div class="panel-body">
<sf:hidden path="contractDetailsId" />
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="piId">Pi Id <font
color="red">*</font></label>
<sf:input path="piId"
placeholder="Please enter Pi Id" type="text"
id="piId" cols="34" rows="4" maxlength="60"/>
<span id="c1" class="label label-warning">This information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="piName">PI Name <font color="red">*</font></label>
<sf:input path="piName" placeholder="Please Enter PI Name"
type="text" id="piName" size="60" maxlength="60" />
<span id="c2" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="studyId">Study Id <font color="red">*</font></label>
<sf:input path="studyId" placeholder="Please Enter Study Id"
type="text" id="studyId" size="60" maxlength="60" />
<span id="c3" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="studyName">Study Name <font color="red">*</font></label>
<sf:input path="studyName" placeholder="Please Enter Study Name"
type="text" id="studyName" size="60" maxlength="100" />
<span id="c4" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="contractType">Contract Type <font
color="red">*</font></label>
<sf:select path="contractType" id="contractType">
<sf:option value="">-- Select Contract Type --</sf:option>
<sf:option value="Actual">Actual</sf:option>
<sf:option value="Additional">Additional</sf:option>
<sf:option value="Lab">Lab</sf:option>
<sf:option value="Extension">Extension</sf:option>
</sf:select>
<span id="c5" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row" id="otherType">
<div class="col-md-12">
<p class="bx-form">
<label for="contractStartDate">Contract Start Date
<font color="red">*</font>
</label>
<sf:input type="date" path="contractStartDate"
placeholder="Please Enter Contract Start Date"
id="contractStartDate" size="60" />
<span id="c6" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row" id="otherType">
<div class="col-md-12">
<p class="bx-form">
<label for="contractEndDate">Contract End Date <font
color="red">*</font></label>
<sf:input path="contractEndDate"
placeholder="Please Enter Contract End Date" type="date"
id="contractEndDate" size="60" />
<span id="c7" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="paymentTerms">Payment Terms <font
color="red">*</font></label>
<sf:select path="paymentTerms" id="paymentTerms">
<sf:option value="">-- Select Payment Terms --</sf:option>
<sf:option value="One Term">One Term</sf:option>
<sf:option value="MileStone">MileStone</sf:option>
</sf:select>
<span id="c8" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row" id="mileStoneGroup">
<div class="col-md-12" id="milestoneDiv">
<p class="bx-form">
<label for="mileStone1">MileStone </label>
<sf:input path="mileStone" placeholder="Please Enter MileStone1"
type='textbox' id="mileStone1" size="60" maxlength="11" />
<button type="button" id="addVariable" name="addVariable">
<img src="../images/save2.jpg" />
</button>
<button type="button" id="removeVariable" name="removeVariable">
<img src="../images/minus.png" />
</button>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="contractOthers">Others</label>
<sf:input path="contractOthers"
placeholder="Please Enter Others" type="text"
id="contractOthers" size="60" maxlength="60" />
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="irbPayment">IRB Payment</label>
<sf:input path="irbPayment" id="irbPayment"
placeholder="Please Enter IRB Payment" type="text" size="60"
maxlength="60" />
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="iecPayment">IEC Payment</label>
<sf:input path="iecPayment" id="iecPayment"
placeholder="Please Enter IEC Payment" type="text" size="60"
maxlength="60" />
</p>
</div>
</div>
<div class="row" id="otherType">
<div class="col-md-12">
<p class="bx-form">
<label for="modeOfPayment">Mode of Payment <font
color="red">*</font></label>
<sf:select path="modeOfPayment" id="modeOfPayment">
<sf:option value="">-- Select Mode of Payment--</sf:option>
<sf:option value="Cheque">Cheque</sf:option>
<sf:option value="Draft">Draft</sf:option>
<sf:option value="Cash">Cash</sf:option>
</sf:select>
<span id="c9" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="inFavorOf">In Favor Of</label>
<sf:input path="inFavorOf"
placeholder="Please Enter In Favor Of" type="text"
id="inFavorOf" size="60" maxlength="60" />
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="paybleAt">Payable At</label>
<sf:input path="paybleAt" id="paybleAt"
placeHolder="Please Enter The Payable At" size="60"
maxlength="60" />
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<label for="panNumber">PAN Number <font color="red">*</font></label>
<sf:input path="panNumber" id="panNumber"
placeHolder="Please Enter The PAN Number" size="60"
maxlength="30" />
<span id="c10" class="label label-warning">This
information is required.</span>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class="bx-form">
<c:choose>
<c:when test='${ACTION_TYPE == "EDIT"}'>
<button type="button" id="updateBtn" class="btn btn-success">Update</button>
</c:when>
<c:otherwise>
<button type="button" id="saveBtn" name="cmd"
class="btn btn-success">Save</button>
</c:otherwise>
</c:choose>
<button type="button" id="cancelBtn" class="btn btn-warning"
onclick="javascript:invokeCancel();">Cancel</button>
</p>
</div>
</div>
</div>
</div>
</div>
</sf:form>
</body>
</html>
Controller:Code
/************************************* Save ContractDetails *****************************/
#RequestMapping(value = "/saveContract", method=RequestMethod.POST)
public ModelAndView saveContractDetails(ContractDetails contractDetails,
BindingResult result) {
contractDetailsService.createContractDetails(contractDetails);
ModelAndView model = new ModelAndView(PagesI.CONTRACT_DETAILS_DISPLAY);
model.addObject("contractDetailsList",
contractDetailsService.getContractDetailsList());
model.addObject("DISPLAY_VIEW_PAGE", "Y");
return model;
}
It seems like your are missing something in your saveContractDetails method inside your controller.
When you submit your form, you are sending a request on "/saveContract" and passing the model attribute contractDetails to it.
In order for Spring to be able to process your request, I think you have to specify inside the declaration of the saveContractDetails method that you are sending a model attribute.
I would try something like that:
#RequestMapping(value = "/saveContract", method=RequestMethod.POST)
public ModelAndView saveContractDetails(#ModelAttribute ContractDetails contractDetails,
BindingResult result) { ... }
Why is request.getParameter("termin"); returning NULL
.The Connection and the Statement for my Databse are correct.It works fine in an more simple Version.
This is JSp/JAva Code:
int result = 0;
if(request.getParameter("submit") != null) {
String name = new String();
if(request.getParameter("termin") != null) {
name = request.getParameter("termin");
}else {
out.println("termin is null");
}
Termin t1 = new Termin();
result = t1.setTermin(name);
Here is the HTML Code :
<form action="index.jsp" method="POST" name="test">
<div class="modal fade" id="bModal" tabindex="-1" role="dialog" aria-labelledby="beispielModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Schließen</span></button>
<h4 class="modal-title" id="beispielModalLabel">Neuer Termin</h4>
</div>
<div class="modal-body">
<!-- <form role="form" action="index.jsp" method="POST"> -->
<div class="form-group">
<label for="empfaenger-name" class="control-label">Name</label>
<input type="text" class="form-control" id="empfaenger-name" name="termin" value="">
</div>
<div class="form-group">
<label for="nachricht-text" class="control-label">Zusätzlich:</label>
<textarea class="form-control" id="nachricht-text"></textarea>
</div>
<!-- </form> -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" id="del" data-dismiss="modal" >Löschen</button>
<input type="submit" name="submit" class="btn btn-primary" id="eintrag" data-dismiss="modal" value="Speichern" >
</div>
</div>
</div>
</div>
</form>
I'm not a Bootstrap expert yet I can see a few potential causes to this issue:
data-dismiss="modal"- looking at:
http://getbootstrap.com/javascript/#modals-related-target it seems that data-dismiss="modal" is used only with "close" buttons - never with "submit"!
the class class="btn btn-primary" is supposed to be used with elements of type button and you're using it with input
using the id attribute might create a conflict with bootstrap autogenerated html-elements, but I'm just guessing here based on your comment above.
I'm trying to write a program that fetches weather information from weather.com by using JSoup. This is what I have so far:
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.jsoup.Jsoup;
public class WeatherComHandler {
private Element ForeCastDiv;
public static void main(String[] args) {
WeatherComHandler wch = new WeatherComHandler("http://www.weather.com/weather/today/Brussels+BEXX0005:1:BE");
wch.getTodaysForeCast();
}
public WeatherComHandler(String url) {
getForeCastDiv(url);
}
private void getForeCastDiv(String url) {
try {
Document doc = Jsoup.connect(url).get();
ForeCastDiv = doc.getElementById("wx-forecast-container");
} catch(Exception e) {
e.getStackTrace();
}
}
public void getTodaysForeCast() {
System.out.println(ForeCastDiv.toString());
System.out.println(ForeCastDiv.hasClass("wx-data-part wx-first"));
Elements todaysElements = ForeCastDiv.getElementsByClass("wx-data-part wx-first");
System.out.println(todaysElements.size());
}
}
This is the output:
<div id="wx-forecast-container">
<div class="wx-today wx-module wx-grid3of6">
<div class="wx-title-container">
<h2 class="wx-title"><img src="http://i.imwx.com/common/My.png" /> Forecast for Today</h2>
<div class="wx-updated">
Updated: Oct 28, 5:45pm Local Time
</div>
<div class="wx-promo-links wx-cond wx-severe wx-severe-0">
<ul class="wx-links">
<li class="wx-icon wx-cond wx-desktop"> <a class="wx-icon wx-cond wx-desktop" href="/apps/desktop-weather" location="" from="today_promo_1" title="Weather on my Desktop">Desktop App</a> </li>
</ul>
</div>
</div>
<div class="wx-weather-details">
<div class="wx-timepart-title wx-first">
Right Now
<div class="wx-module wx-grid1of6 wx-weather wx-love-module wx-cond-bg">
<div class="wx-module-inner">
<div class="wx-icon wx-social wx-balloon-wt-lt wx-clickable wx-love-ugh" data-good="true" data-share-trx="" data-share-icon="http://s.imwx.com/img/common/social/lmw-love.jpg" title="Love My Weather" data-share-desc="It's 55°F, Clear">
<div class="wx-icon wx-social wx-heart"></div>
<h4 data-share-title="Love! Right now in Brussels, Belgium"></h4>
</div>
<div class="wx-icon wx-social wx-balloon-wt-rt wx-clickable wx-love-ugh" data-good="false" data-share-trx="" data-share-icon="http://s.imwx.com/img/common/social/lmw-ugg.jpg" title="Don't Love My Weather" data-share-desc="It's 55°F, Clear">
<h4 data-share-title="Ugh! Right now in Brussels, Belgium"></h4>
</div>
</div>
</div>
</div>
<div class="wx-timepart-title">
Earlier Today
</div>
<div class="wx-timepart-title">
Tonight
</div>
<div class="wx-data-part wx-first">
<img src="http://s.imwx.com/v.20131006.214956/img/wxicon/120/31.png" height="120" width="120" alt="Clear" class="wx-weather-icon" />
</div>
<div class="wx-data-part">
<img src="http://s.imwx.com/v.20131006.214956/img/wxicon/120/34.png" height="120" width="120" alt="Fair / Windy" class="wx-weather-icon" />
</div>
<div class="wx-data-part">
<img src="http://s.imwx.com/v.20131006.214956/img/wxicon/120/29.png" height="120" width="120" alt="Partly Cloudy" class="wx-weather-icon" />
</div>
<div class="wx-data-part wx-first">
<div class="wx-temperature">
<span itemprop="temperature-fahrenheit">55</span>
<span class="wx-degrees">°<span class="wx-unit">F</span></span>
</div>
<div class="wx-temperature-label">
FEELS LIKE
<span itemprop="feels-like-temperature-fahrenheit">55</span>°
</div>
</div>
<div class="wx-data-part">
<div class="wx-temperature">
62
<span class="wx-degrees">°</span>
</div>
<div class="wx-temperature-label">
HIGH AT 11:45 AM
</div>
</div>
<div class="wx-data-part">
<div class="wx-temperature">
47
<span class="wx-degrees">°</span>
</div>
<div class="wx-temperature-label">
LOW
</div>
</div>
<div class="wx-data-part wx-first">
<div class="wx-phrase ">
Clear
</div>
<div class="wx-obs-qualifier ">
<span class="wx-hide" itemprop="observation-qualifier">OQ1190</span>
<span class="wx-hide" itemprop="observation-qualifier-severity">2</span>
<span itemprop="observation-qualifier-phrase">Locations nearby are reporting rain with wind.</span>
</div>
</div>
<div class="wx-data-part">
<div class="wx-phrase ">
Fair / Windy
</div>
</div>
<div class="wx-data-part">
<div class="wx-phrase ">
Partly Cloudy
</div>
</div>
<div class="wx-data-part wx-first">
<h6 class="wx-label">Past 24-hr Precip:</h6>
<div class="wx-data">
0.34 in
<span class="wx-estimated">(est.)</span>
</div>
</div>
<div class="wx-data-part">
<h6 class="wx-label"></h6>
<div class="wx-data"></div>
</div>
<div class="wx-data-part">
<h6 class="wx-label">Chance of <span class="wx-firstletter">rain</span></h6>
<div class="wx-data">
<span class="wx-icon wx-raindrop"></span>20%
</div>
</div>
<div class="wx-collapsible">
<div class="wx-data-part wx-first wx-wind">
<h6 class="wx-label">Wind:</h6>
<div class="wx-data">
<div class="wx-icon wx-dir-arrow-sm wind-dir-SW"></div>
<div class="wx-wind-label">
SW at 17 mph
</div>
</div>
</div>
<div class="wx-data-part wx-wind">
<h6 class="wx-label"></h6>
<div class="wx-data">
<div class="wx-wind-label"></div>
</div>
</div>
<div class="wx-data-part wx-wind">
<h6 class="wx-label">Wind:</h6>
<div class="wx-data">
<div class="wx-icon wx-dir-arrow-sm wind-dir-SW"></div>
<div class="wx-wind-label">
SW at 18 mph
</div>
</div>
</div>
<div class="wx-data-part wx-first">
<h6 class="wx-label">Humidity:</h6>
<div class="wx-data">
76%
</div>
</div>
<div class="wx-data-part">
<h6 class="wx-label"></h6>
<div class="wx-data"></div>
</div>
<div class="wx-data-part">
<h6 class="wx-label">Humidity:</h6>
<div class="wx-data">
82%
</div>
</div>
<div class="wx-data-part wx-first">
<h6 class="wx-label">UV Index:</h6>
<div class="wx-data">
0 - Low
</div>
</div>
<div class="wx-data-part">
<h6 class="wx-label"></h6>
<div class="wx-data"></div>
</div>
<div class="wx-data-part"></div>
<div class="wx-data-part wx-first ">
<h6 class="wx-label"></h6>
<p class="wx-text"></p>
</div>
<div class="wx-data-part ">
<h6 class="wx-label"></h6>
<p class="wx-text"></p>
</div>
<div class="wx-data-part ">
<h6 class="wx-label">Tonight:</h6>
<p class="wx-text">Partly cloudy skies. Low 47F. Winds SW at 15 to 25 mph.</p>
</div>
<div class="wx-astro-neighbor">
<div class="wx-data-part wx-first">
<h6 class="wx-label">Pressure:</h6>
<div class="wx-data">
<span itemprop="barometric-pressure-incheshg"> 29.59 in </span>
<span class="wx-icon wx-dir-arrow-sm wx-pressure-steady"></span>
</div>
</div>
<div class="wx-data-part wx-first wx-dewpoint">
<h6 class="wx-label">Dew Point: <span class="wx-icon wx-long wx-info"> <i>Humidity becomes more noticeable as the dew point rises above 60°F. Readings above 75°F can feel stifling.</i> </span> </h6>
<div class="wx-data">
47°
</div>
</div>
<div class="wx-data-part wx-first">
<h6 class="wx-label">Visibility:</h6>
<div class="wx-data">
6.0 mi
</div>
</div>
</div>
<div class="wx-astro-details">
<h3 class="wx-astro-title">Sun & Moon</h3>
<dl class="wx-first">
<dt>
Sunrise:
</dt>
<dd>
7:28 am
</dd>
<dt>
Sunset:
</dt>
<dd>
5:25 pm
</dd>
</dl>
<dl>
<dt>
Moonrise:
</dt>
<dd>
12:27 am
</dd>
<dt>
Moonset:
</dt>
<dd>
2:32 pm
</dd>
</dl>
<dl class="wx-moonphase-container">
<dt>
Moonphase:
</dt>
<dd>
<div class="wx-icon wx-moonphase wx-moon-23"></div>
<div class="wx-moonphase-label">
Waning Crescent
</div>
</dd>
</dl>
</div>
</div>
</div>
<div class="wx-toggle-collapsible-container">
<div class="wx-toggle-collapsible wx-clickable">
<div class="wx-control wx-expand-control" tracktype="action" trackstr="today_rightnow_showmore">
<span class="wx-icon wx-arrow wx-mb-lg-dn"></span>Open Weather Details
</div>
<div class="wx-control wx-collapse-control wx-hide" tracktype="action" trackstr="today_rightnow_showless">
<span class="wx-icon wx-arrow wx-mb-lg-up"></span>Close Weather Details
</div>
</div>
</div>
<div class="wx-pagination-linkers">
<div class="wx-next-linker">
<ul class="wx-links">
<li class=""> <a class="" href="/weather/hourbyhour/graph/Brussels+BEXX0005:1:BE" location="" from="today_rightnow-Today_tempGraph_1" title="">Hourly Forecast</a> </li>
</ul>
</div>
</div>
</div>
<script>$("#wx-icon wx-long wx-info").attr('title','This is the hover-over text');</script>
<div id="wunderground-lightbox" class="wx-dialog">
<div class="wx-close" title="Close">
<div class="wx-icon"></div>
</div>
</div>
<div class="wx-combinedPromo wx-module wx-grid3of6">
<div class="wx-commuter-promo" data-classname="wx-grid-2" from="today-commuterpromo" data-layers="traffic,weather" data-locationinus="false" data-backgroundimageurl="" data-location-zoom="10" data-location-latitude="50.85045" data-location-longitude="4.34878">
<div class="wx-commute-promo-callout-title">
<div class="wx-titleIconHolder">
<img class="wx-titleIcon" src="http://s.imwx.com/img/module/TrafficCams_16x16.png" />
</div>
<div class="wx-titleText">
NEW! Traffic & Commuter Forecast
</div>
</div>
</div>
</div>
<div class="wx-clear"></div>
<div class="wx-scroll-tracking wx-scroll-pres" data-modulecode="ScrollTracking1_Today" data-location="BEXX0005:1:BE" data-groupname="weblocal"></div>
<div class="wx-free-title ">
<h3>Latest Stories</h3>
</div>
<div id="wx-rightnowsecond-container">
<div id="wx-rightnow-container">
<div class="wx-module wx-mod1 wx-corsican wx-1x155M wx-render-mode" id="mod_4" data-vr-zone="today_beta_Media_top2">
<div class="wx-inner" data-vr-contentbox=""></div>
</div>
<div class="wx-module wx-mod1 wx-corsican wx-1x155M wx-render-mode" id="mod_5" data-vr-zone="today_beta_Media_top1">
<div class="wx-inner" data-vr-contentbox=""></div>
</div>
</div>
<div class="wx-module wx-trending-stories wx-tabbed-content wx-grid2of6">
<div class="wx-inner">
<h2 class="wx-title">Most Popular</h2>
<ul class="wx-tabs" data-vr-zone="Most Popular">
<li class="wx-tab wx-active" data-tab="today" data-vr-contentbox="">Today</li>
<li class="wx-tab wx-clickable" data-tab="this_week" data-vr-contentbox="">This Week</li>
</ul>
<ul class="wx-tab-content" data-tab="today" data-vr-zone="Most Popular">
<li data-vr-contentbox="">Superstorm Sandy: Then and Now (EXCLUSIVE PHOTOS)</li>
<li data-vr-contentbox="">Eerie Nighttime Shots of Abandoned America</li>
<li data-vr-contentbox="">Astounding Fall Photos That Will Make You Say 'Wow!'</li>
<li data-vr-contentbox="">Nightmares Fear Factory: Terrified Reactions at Haunted House (PHOTOS)</li>
<li data-vr-contentbox="">The 15 Worst U.S. Cities for Asthma</li>
<li data-vr-contentbox="">Shocking End to Shark Attack <span class="wx-icon wx-video wx-trending-video"></span></li>
<li data-vr-contentbox="">Gigantic Hornets Are Breeding <span class="wx-icon wx-video wx-trending-video"></span></li>
<li data-vr-contentbox="">18-Foot WHAT? <span class="wx-icon wx-video wx-trending-video"></span></li>
</ul>
<ul class="wx-tab-content" data-tab="this_week" style="display:none;" data-vr-zone="Most Popular">
<li data-vr-contentbox="">Superstorm Sandy: Then and Now (EXCLUSIVE PHOTOS)</li>
<li data-vr-contentbox="">Nightmares Fear Factory: Terrified Reactions at Haunted House (PHOTOS)</li>
<li data-vr-contentbox="">Eerie Nighttime Shots of Abandoned America</li>
<li data-vr-contentbox="">8 Deadly Venomous Creatures and Those Who've Survived (PHOTOS)</li>
<li data-vr-contentbox="">Astounding Fall Photos That Will Make You Say 'Wow!'</li>
</ul>
</div>
</div>
</div>
<div class="wx-map wx-cc-map wx-grid3of6 wx-module pagelet " data-severelocation="false" data-location="BEXX0005" data-location-type="1" data-overlay="" data-zoom="" data-tropical="" data-mapsize="3" data-fragid="frag_newccMap_166739" data-modulecode="beta_CCMap" data-pageid="62288">
</div>
</div>
false
0
The problem is getTodaysForeCast() keeps saying that the size of todaysElements is 0, which it shouldn't be. Could anyone explain me why this is happening or what I'm doing wrong?
thanks in advance.
Jsoup will not accept two combined classes in the getElementsByClass method. Try something like:
Elements todaysElements = ForeCastDiv.getElementsByAttributeValueContaining("class", "wx-data-part wx-first");
You're passing two separate class names (separated by a space) to both hasClass() and getElementsByClass(), both of which can only handle one class at a time.
Try using select() instead. It allows you to use complex CSS selectors to find elements, like this:
ForeCastDiv.select(".wx-data-part.wx-first")