I pressed F12 in Chrome, and I can see my code.
How do I copy the code. (see screenshot)
I am able to press ellipses on the left, select Copy, then select Copy Element.
It copies into buffer and I can paste from it.
But whatever I get is not well formatted.
If I want to be able to ask a question on the board about something, this sort of paste would be very unfriendly for the person wanting to answer the question.
Screenshot
Try to copy the first or second line that will bring you the whole html. The exact line is
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>...
Try to copy outerHTML. I don't know if this works or is what you want.
The best thing I have found it to save as xml and attach.
You can also take screenshots of html code when you post question to board.
Reason is that nobody really modifies the source code of the website.
For best results in copying HTML code from a website, I recommend using the free version of CoffeCup HTML editor
EDIT: A better way to do this within Chrome itself is to put "view-source:" before the website name. Example: view-source:http://example.com. It is formatted the way the website wrote it.
Related
I am creating automation that automatically sends messages through LinkedIn. The code is working fine, but as per our current requirement, I want to click on the attachment button so as to pass the attachment also with the text message. There are a few points that I have already tried:
Unable to fetch the element ID as its dynamic most of the time.
Don't want to use offsets (x,y) because once anyone changes the size of the window offsets changes.
Unable to use XPath.
Then I checked for another tool "UIVision" which makes a solution to capture that particular area (save it in a .png file) from the page where we want to click and during runtime it clicks there. So I tried searching image comparison API for java, tried with ASHOT and Sikulix too but none worked for me.
Anyone can help me with this?
When you say your unable to use xpath will you please elaborate?
The button has an id - it's attachment-trigger-ember1079.
If you're concerned about the latter part being dynamic, the attachment button also has a good title.
You can try using xpath string:
//button[contains(#title,'Attach a file')]
For me, on my linked in, this returns a unique hit on the expected attachment object:
If these don't work, there's also the option of using javascript to action the upload.
For more information on handling the upload dialog (after your identify the object) have a look here
Let me start off with saying that I've seen some questions in this regard but nothing actually specifically answering my issue.
Let's say I have a template version of a PDF received by someone else. It's a classic PDF that looks like a form but only one part is editable, the other parts are not because they are being filled in with data from an imported excel sheet. (Sadly I can't show an example)
I've been able to do most in iText 7 but I can't figure out for the life of me if I can change a flat text field into an editable form field, like on image 1.
Image 2 shows checkboxes that I want to make editable as well but I can only change their value within java and even then it only shows a cross, not a checkmark (even if I change the checktype).
It's a bit hard to explain but tl:dr is that I just want to know whether I can edit an existing flat PDF in java or if I have to do so in adobe itself.
Thanks
I am using Selenium to build a test automation where the html is in an iFrame, I was able to find online the lines of code to activate the iFrame, click on a link, and press a button and they are working fine -see following lines:
driver.SwitchTo().Frame("06634000000BVL6");
driver.FindElement(By.LinkText("Loan Details R1")).Click();
driver.FindElement(By.XPath("//button[contains(.,'Edit')]")).Click();
I needed to input a text within a textBox in that iFrame, but I couldn't handle the ID or the Class, below is the HTML for the input:
Any thoughts ?
Thanks for your help
I can't comment yet, so this will be part answer, part comment.
Based on what you have posted, it looks like you may not be in the correct iframe and we don't have enough of the code from the webpage to tell if there is an additional iframe.
I'd also like to see the code you are using to write text to the field, you may have an issue there.
If you don't and the only issue you have is the selector then try the following. Go get the developer version of firefox. Navigate to your webpage in firefox. Inspect the element where you want to write text to. Once you are in the inspection screen, there is a path bar that can scroll left and right at the bottom of the screen. Check that to confirm that there is only the one iframe you mentioned and that you are in the correct iframe. If that is the issue, you should be good to go, you're code above works for switching between frames. If you are in the right iframe, then try a different method of finding the element for the text box. I have had the most success with hard to find elements by using the cssselector. To get the cssselector for the element right click on it, navigate to copy and then cssselector. From there your code should look like this (using c#):
driver.FindElement(By.CssSelector("INSERT CSS SELECTOR HERE")).SendKeys("Text");
i am trying to navigate through pages using selenium web driver and i am stuck at one point
please refer to the image where i have shown the output of inspect element for that page that i am working on.
but in the page source (which i saw on the browser and also using Jsoup) looks like this,
<html>
<head>
</head>
<frameset rows="75,60,*" resize="no" SCROLLING="NO" name=main border="0">
<frame src="/frame/topnewprof.shtml" name="top" SCROLLING=NO>
<frame src="/frame/blank.html" name="menu" SCROLLING=NO >
<frame src="/itrade/user/welcome.exe?action=chk_seckey_stat" name="body" SCROLLING=AUTO>
</frameset>
<body>
</BODY></html>
why is this mismatch? and the yellow stuff that i have highlight in the image above has the element that i need!!
how will i get there using selenium??
i know that we can navigate into the iframe using selenium's switchTo().frame() but even if i get into any of the three frames as shown above in the page source information, i'm not able to find the information i need,
can this be achieved ? is it even possible?
UPDATE:
hello guys! i found the solution to this and now that huddle is crossed.
actually what happened was , when i was trying to do getPageSource, selenium was actually getting the frame source of one of the frames ("body" - as mentioned above), i accidentally figured that out.
Next to solve my problem i wanted to come one step back from where i was so i can select this iframe = (name="top") which was the target where i had the content as shown in the image. to Achieve this i used Selenium's defaultContent() function and came back one step then with switchTO().frame() went into the frame of my desire and accomplished the task
hope this helps!!
and thanks for everyone who tried to help me on this.
I couldn't exactly tell you why this mismatch is caused but I have an idea of how you could solve this problem.
I had similar problems with javascript phrases on pages. Normally such elements have to be clicked to get into. But if this element isn't clickable or a click doesn't sole the problem you could also search the information you need by using unique Xpath's.
I'm not sure if you using Selenium IDE already but maybe you could record navigating to this element and use the thrown java code from the Selenium IDE to get the required Information.
... I only have seen this problem while using Selenium remote control not the Selenium WebDriver...
I think the problem could also be solved by using xpaths. The easiest way to get the correct xpath is using firebug with firefox. Right click on the element in developer tools and click copy xpath. Firebug's incredibly accurate when producing xpaths. It has solved many problems like that one for me.
*Even if you aren't using firefox, most of the time you can use the same xpath from firebug in chrome webdriver testing.
It's a life saver.
Warning though, sometimes the path is long like:
final static String planTitlePath = "/html/body/div[1]/div[2]/div[1]/div[2]/div[5]/div/div/div/div/section/div/div[2]/div/ol/li/div[1]/plan-card/h4/span";
i found the solution to this and now that huddle is crossed. actually what happened was , when i was trying to do getPageSource, selenium was actually getting the frame source of one of the frames ("body" - as mentioned above), i accidentally figured that out. Next to solve my problem i wanted to come one step back from where i was so i can select this iframe = (name="top") which was the target where i had the content as shown in the image. to Achieve this i used Selenium's defaultContent() function and came back one step then with switchTO().frame() went into the frame of my desire and accomplished the task
hope this helps!! and thanks for everyone who tried to help me on this.
I am using eclipse with tomcat server. My program is about to print a page containing dynamic table, which means the data and number of column even header title also dynamic. The table is continue to the next page, and i need to view the table header as well as the first page. Is there any example or page i can refer to?
Thanks in advance
your explanation is not clear enough but based on your question (How to preview before print using eclipse?) I think I know what you mean. as I realized you want to have a preview before printing your page, Ok then, jQuery has a plugin with this very aim which is called Print Preview Plugin. use this plugin and:
$('#yourcontainer').prepend('<a class="preview-page">Print this page</a>');
$('a.preview-page').printPreview();
then you can call $.printPreview.loadPrintPreview(); and your problem is solved. here this is a DEMO get a view-source, you'll see the solution.