Selenium IDE - sendKeys to page/body element - xpath

In Selenium IDE I'm trying to invoke some key shortcuts in browser. For example let's say I want to reload http://www.google.com page with:
Command: sendKeys
Target: //body
Value: ${KEY_F5}
Script passes, but is not working. Switching to any frame first also not working.
In webdriver I'm successfully using:
driver.findElement(By.xpath("//body")).sendKeys(Keys.F12);
I'm aware of refresh command in IDE, but it won't solve my problem because what I really need to do is send different F1-12 keys...
Am I missing something?
I've also tried click first at body element but I'm not able to make it work and send any F1-12 keys to window/page and not to an element.

Run the following code and you will see how your sendKey KEY_F5 is working. when script reaches sendKeys, the searchbar is being triggered It is my guess that body is being refreshed not the whole document. Not sure..though
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.com/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/?gws_rd=ssl</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=lst-ib</td>
<td>dsad</td>
</tr>
<tr>
<td>click</td>
<td>name=btnG</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>//*</td>
<td>${KEYS_F5}</td>
</tr>
</tbody></table>
</body>
</html>

Related

Thymeleaf can't see For-each variable

Here is my Service ( It just gets a list of entities )
#Service
public class ProcedureService {
#Autowired
ProcedureRepository procedureRepository;
public List getProceduresList() {
List<Procedure> procedureList;
procedureList = procedureRepository.findAll();
return procedureList;
}
}
Here is my Controller. It just puts list he gets to view.
#Controller
public class ServicesController {
#Autowired
ProcedureService procedureService;
#GetMapping("/services")
public String getCustomer(Model model) {
List<Procedure> procedures = procedureService.getProceduresList();
model.addAttribute("procedures", procedures);
return "services";
}
}
And here is my real problem. Thyme leaf just doesn't see the entity in a List ( it sees the list though ). Here is my screen and full code of View
<!DOCTYPE html>
<html lang="en">
<head>
<title>SpringMVC + Thymeleaf + Bootstrap 4 Table Example</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h1>Customer Table</h1>
<div class="row col-md-7 table-responsive">
<table id="customerTable" class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Age</th>
<th>Street</th>
<th>Postcode</th>
</tr>
</thead>
<tbody>
<tr th:each="procedure: ${procedures}">
<td th:text="${procedure.}" />
<td th:text="${procedure.getId}" />
</tr>
</tr>
</tbody>
</table>
</div>
</div>
I forgot about html lang="en" xmlns:th="http://www.thymeleaf.org" in html so th wasn't really working.

vue.js: Error while using v-for

I want to render a table dynamically, based on ajax requests. The Backend is set up properly and when I execute the code the data from the response package is successfully loaded into my variables.
However, when viewing it in the browser, console logs the following error:
[Vue warn]: Failed to generate render function:
SyntaxError: Unexpected token - in
with(this){return _c('div',{attrs:{"id":"app"}},[_m(0),_v(" "),_c('table',[_c('tbody',[_c('tr',_l((header),function(head-item){return _c('th',{domProps:{"textContent":_s(head-item)}})})),_v(" "),_l((data),function(entry){return _c('tr',_l((entry),function(item){return _c('td',{domProps:{"textContent":_s(item)}})}))})],2)])])}
(found in <Root>)
My app.js file:
new Vue({
el: '#app',
data: {
header: [],
data: [],
},
mounted() {
axios.get('/contacts').then(response => this.load_response(response));
},
methods: {
load_response(response) {
this.header = response.data.header;
this.data = response.data.data;
}
}
});
And my html-file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TestProject</title>
<body>
<div id="app">
<table>
<tr>
<th>TestHeader/th>
</tr>
<tr>
<td>TestItem</td>
</tr>
</table>
<table>
<tr>
<th v-for="head-item in header" v-text="head-item"></th>
</tr>
<tr v-for="entry in data">
<td v-for="item in entry" v-text="item"></td>
</tr>
</table>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.3/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="/js/app.js"></script>
</body>
</html>
When I try it in the browser, the first (dummy) table is shown for half a second or so, before it gets hidden. Then the page is blank.
EDIT: The json received from the server is in the form
{
header: [foo, bar, foobar...],
data:[[foo, bar, footer], [foo2, bar2, foobar2], ...]
}
You cannot use a dash in an identifier in v-for. Try
<th v-for="headItem in header" v-text="headItem"></th>
Dash isn't a valid character for any JavaScript variable.

Spring MVC : Jsp file does not display data from the controller

This is my controller code
#RequestMapping(value="/testMvc")
public String testero(Model model ){
String nameClient="HENOCKE";
Long CodeClient=2L;
String Address="LONDO Street";
System.out.println("****End and outputting to Jsp page: ****");
return "rs";
}
And as you can see i want to display data to my jsp files and this is my jsp file:
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%#taglib uri="http://www.springframework.org/tags/form" prefix="f"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" charset=UTF-8>
<title>Banque </title>
<link rel="stylesheet" type="text/css"
href="<%=request.getContextPath()%>/resources/CSS/style1.css">
</head>
<body>
<h2>Date Loaded from My controller....</h2>
<table>
<tr>
<th>Name : </th> <th><c:out value="${nameClient}"/></th>
</tr>
<tr>
<th>id Client: </th> <th> <c:out value=" ${CodeClient}" /> </th>
</tr>
<tr>
<th>Adress client: </th> <th> <c:out value="${Address}" /></th>
</tr>
</table>
</body>
</html>
How can i output data to my jsp? here rs is the Name of my Jsp file
You need to add the attributes to the model.
String nameClient = "Whatever";
model.addAttribute("nameClient",nameClient);
Read this:
http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/mvc.html
You should create ModelAndView object to put values to view:
#RequestMapping(value="/testMvc")
public ModelAndView testero(){
ModelAndView mov = new ModelAndView("rs");
mov.addAttribute("nameClient", "HENOCKE");
mov.addAttribute("CodeClient", 2L);
mov.addAttribute("Address", "LONDO Street");
System.out.println("****End and outputting to Jsp page: ****");
return mov;
}

Pure ASP upload with utf-8 filenames

I'm have made a upload page in classic asp and it works fine, as long as the filenames are not in utf-8 characters. I have added charset til the page and the form accepts utf-8 characters but my files are saved as Доклад Региона.pdf bug should be Доклад Региона.pdf
I don't know if there is anything more I can do or it is the "Pure-ASP file upload" that does not support utf-8 characters.
Does anyone how to fix it?
My asp page looks like this
<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="upload2.asp"--><%
dim File
DestinationPath = Server.mapPath("Files")
If Form.State = 0 Then 'Completted
For Each File In Form.Files.Items
If Len(File.FileName) > 0 Then
Form.Files.Save DestinationPath
End If
Next
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Project Site</title>
<link id="ss__cs" rel="stylesheet" href="CSS/stylesheet.css" type="text/css"/>
</head>
<body style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; padding: 0;" >
<form method="POST" id="myform" ENCTYPE="multipart/form-data" acceptcharset="UTF-8">
<table>
<tr>
<td>File</td>
<td><input type="file" id="File1" name="File1" class="defaultfont"></td>
</tr>
<tr height="10">
</tr>
<tr>
<td></td>
<td><input Value="Cancel" Type="button" class="defaultfont" onclick="window.close()"> <input Value="Upload file" Type="submit" class="defaultfont" ></td>
</tr>
</table>
</Form>
</body>
</html>
Try adding
If Form.State = 0 Then 'Completted
'Add this line to set the character set based on the response.
Form.CharSet = Response.CharSet
For more information see Upload - use unicode (utf-8) character set for request/response data .

DOCTYPE not working in Firefox

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<Script language = JavaScript>
function addOptionList(selectbox,text,value )
{
var optn = document.createElement('OPTION');
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}
function removeOptionList(listbox,i){
listbox.remove(i);
}
function addOption_list(fromvar,tovar){
for(i=fromvar.options.length-1;i>=0;i--) {
var userlist=fromvar;
if(fromvar[i].selected){
addOptionList(tovar, fromvar[i].value, fromvar[i].value);
removeOptionList(userlist,i);
}
}
}
</Script>
<table align='center'>
<tr>
<td ><select multiple name='userlist' id='userlist' >
<option value='aaa'>aaa</option>
<option value='bbb'>bbb</option>
</select></td>
<td align='center' valign='middle'>
<input value='-->'
onClick='addOption_list(userlist,pouser);' type='button'>
<br><input value='<--'
onClick='addOption_list(pouser,userlist);' type='button'></td>
<td><select multiple name='pouser' id='pouser'>
<option id='test' value='ccc'>ccc</option>
</select></td>
</tr>
</table>
</body>
</HTML>
I am using the code above to select a name from left box and move it to the right box. The code is working in IE with/without DOCTYPE. But when I use DOCTYPE, it stops working in Firfox. I have spent a lot of time on it, but still couldn't figure out the problem. Also, I am a novice in Javascript, so please explain me the problem with code below (when I am using DOCTYPE). Thanks in advance for your help!!
You're relying on elements with ids showing up as global properties on the window (e.g. userlist). Firefox only does that in quirks mode, which is why the doctype matters.
Your markup does not match the DOCTYPE. I.e. you are not using valid XHTML 1.0 markup.
Paste you code into the xhtml validator and it will show you what's wrong.

Resources