targeting div in some other page - html

I have two pages say abc and xyz
in abc i have an anchor tag, and when i click on that it should go to some div in page xyz.
i used in the page abc
and in xyz i put ... before that div..what am i missing?

You add a # and the value of the id of the element you are targeting to the end of the URL:
http://example.com#id_value_of_target_element

Related

Extracting Text from a HTML Table with no Identifier/Name via Selenium

I'm trying to figure out how to extract the results generated from this site:
mailtester.com when entering a full email. Take the email address laura.singer#pfizer.com for example. After entering this address and clicking submit, a HTML table thats highlighted green will show up. I want to get the text "Email address is valid" which is the 5th child of the 5th row of this table it seems. However, there are no ids or names, and there are two tables, so its a bit tricky.
This is what I have right now:
wait = WebDriverWait(self.browser, 300)
inputEmail=wait.until(EC.presence_of_element_located((By.NAME, "email")))
inputEmail.clear()
inputEmail.send_keys(email)
inputEmail.submit()
somethin = self.browser.find_element_by_xpath("//table")
somethin = somethin.text
print(somethin)
It prints "Email address" which is incorrect. Looks like there are two tables which do not have ids or names.
Try this CSS selector. It basically means find the TABLE tag that is a child (>) of an element with an ID (#) content
somethin = self.browser.find_element_by_css_selector("#content > table")

Selenium: How to get text from within an html tag which has another tag in it

<a class="spf-link current" href="/orders/returns?offset=0&limit=25">
<span class="pg-helpText">Page</span>
1
</a>
I need to read the value '1' in my test. When I do a get text using css-selector .spf-link.current, it gets me "Page 1". I only need '1'. How do I exclude the text from the span tag.
You will need Javascript childNodes to get the text from the nodes.
The childNodes property returns a collection of a node's child nodes,
as a NodeList object.
The nodes in the collection are sorted as they appear in the source
code and can be accessed by index numbers. The index starts at 0.
WebElement element = driver.findElement(By
.cssSelector(".spf-link.current"));
String node_text=(String)((JavascriptExecutor)driver)
.executeScript("return arguments[0].childNodes[2].nodeValue",element);
This should give you the value 1 as node_text when you run the JavascriptExecutor. Other way is to split the text Page 1 on the basis of space. But, i would prefer childNodes.
Let me know if you have any queries.
Try the following:
//span[#class="pg-helpText" and contains(text(), 'Page')]/following-sibling::span/span
It is not normal to customize untagged text between tags.
I recommend you to change the value to your desired result:
<a class="spf-link current" href="/orders/returns?offset=0&limit=25">1</a>
...and when you want to show it in other place, do it as var ThePage = "Page " + [the page number]
Other solution is to include it into another tag as a div or as another span with a different class or id.

How to give page break in SSRS

I am making a very simple report in SSRS. I am trying to do the following:
On page 1 display following text
THIS IS PAGE 1
On page 2 display following text
THIS IS PAGE 2
I added "Text" field in my report in which I have set the value field to "THIS IS PAGE 1". But I can't find any option to add page break after it. How do I give page break?
I am not sure what is the purpose of having Page Break for you without any content..
but still i tried by adding a table on a report with one column and hide that and it works
Step 1
Create a DataSet with query (commandtext)
Select 'A' AS GRP
UNION
Select 'B' AS GRP
Step 2
Insert a table & set DataSetName as created in step1
Step 3
Click on Table Group & press F4 to Set Page Break Properties value,
Set BreakLocation to Between & PageName to =Fields!GRP.Value (See screenshot for your Ref)
Step 4
From above Step you will see report break into 2 page as there are 2 records from query step 1.. Now next step is to Display Page Number for the insert PageHeader
Step 5
Insert Page Header with textbox expression value as
="THIS IS PAGE " & CSTR(Globals!PageNumber)
Last but not least, Hide unexpected table columns (TextBox) as you just want to display Page Number or Page Header
Output of the report will be like

$_POST the name of a div that is clicked

How would I post the id of a div that is clicked? The goal is to have a user click one of several squares and post the name of that square in the url and reload the page with that new url. Any suggestions?
I tried to use :
<div id="boxone1" onclick="window.location='index.php?name=<? print $_POST['id'] ? >';" style="cursor:pointer;">
</div>
But that does nothing and wont reload my page
The goal is to have the user be able to click on the divs in a certain order and have that order match up against a predetermined order. But to make it more complicated, each div is given a random color (one of about 10 colors)each time the page reloads. Therefore, it is the colors that color of the divs that will need to match the predetermined password.
I'm not a big fan of inline javascript such as onclick events, but see a possible answer below (if dynamically producing these divs):
<div id="boxone1" onclick="window.location='?name='+this.id" style="">
Else you could always just do:
<div id="boxone1" onclick="window.location='?name=boxone1'" style="">

<span> </span> in Table<td>

I have a time table as below:
<table id="timetable">
<tr><td>00:00</td><td id="tm0"></td></tr>
<tr><td>00:30</td><td id="tm1"></td></tr>
<tr><td>01:00</td><td id="tm2"></td></tr>
<tr><td>01:30</td><td id="tm3"></td></tr>
</table>
so if i want insert <span></span> into <td> start from id="tm0" - id="tm3" how can i make it ?? instead of "rowspan" can anyone help ??
First get td elements using getElementById if you want frm 0 to 3 loop through the elements using something like ById("tm"+i).
Create the span element using creatingElement and set its properties.
Append this new element to the element retrieved in setp 1.
http://www.w3schools.com/DOM/dom_element.asp
But you are asking for this, in place of rowspan- which carries dynamic values. So i'm not user if i answered your query. But let us know why you want to use span in place of rowspan ?
Using jquery you can do it like following process:
$('table td:last-child').append('<span></span>');
You can't. Elements are arranged in a hierarchy. If the start tag for X is a child of Y, then the end tag for X must also be a child of Y.