I am using Selenium(Java) with Chrome to access the following website:
https://www.ebay-kleinanzeigen.de/m-einloggen.html?targetUrl=/
The Problem is that it always displays a blank page. Here is my Code:
ChromeOptions cap = new ChromeOptions();
cap.setBinary("C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\Users\\Admin\\Downloads\\chromedriver_win32beta\\chromedriver.exe");
WebDriver driver=new ChromeDriver(cap);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
try {
driver.get("https://www.ebay-kleinanzeigen.de/m-einloggen.html?targetUrl=/");
}catch(Exception e){
System.out.println(e);
}
Every other website I have tried works just fine, but this one doesn't want to show up. I have tried to access this website from Firefox, Chrome and Edge, which also show a blank page. I am using Selenium(3.141.59), ChromeDriver(81.0.4044.20) and Chrome Beta(81.0.4044.62).
Here is the HTML Code when I ispect the website:
It looks like this site can detect Selenium and do not open with it.
You can hide it using Chrome Options. Try adding arguments like this before openning the url:
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-blink-features=AutomationControlled");
ChromeDriver driver = new ChromeDriver(options);
Hope this helped, good luck!
It works with selenium stealth and the following options
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
I experienced the same issue. Check if the page you requested returns a successful HTTP status code like 200. In my case, it returned a 40x error which resulted in a blank page.
Related
I am running Selenium to test a specific area of my companies webpage. What I am trying to do seems relatively easy in theory, but I have ran into several obstacles. Can someone please tell me why the URL is opening but won't select the "Services" Hyperlink?
Below is a snippet of the code:
System.setProperty("webdriver.ie.driver","Path to IE/IEDriverServer_64.exe");
WebDriver driver = new InternetExplorerDriver();
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
driver.get("https://www.ups.com/us/en/Home.page");
driver.manage().window().maximize();
driver.findElement(By.xpath(".//*/div[#id='ups-header']/nav[#id='ups-navItems']/ul[#class='ups-navItems_primary']/li[#class='ups-navMenu ups-menu'][3]/a[#id='ups-menuLinks2']")).click();
As I stated earlier, in theory this should open up UPS's homepage and select the "Services" tab on the top right of the page. Instead it just goes to UPS.com homepage and stays there.
I have driver.findElement(By.xpath........); in this example but I have tried findElement(By.name & partialLinkText
Can anyone give me a solution besides update to latest version(s)?
Metadata:
Windows 10,
JAVA 10,
Internet Explorer (Unfortunately) 11.4.
Thanks in advance!
Edit with additonal HTML structure:
This is a portion of the HTML I am working with. This HTML belongs to the Services link I want to click in my automation:
<a role="button" href="#" class="ups-analytics ups-menu_toggle" data-
content-block-id="M1" data-event-id="22" aria-expanded="false" id="ups-
menuLinks2" aria-controls="ups-menuPanel2">Services<span class="ups-mobnav-
arrow" aria-hidden="true"></span></a><div class="ups-menu_list ups-cols-3"
aria-hidden="true" role="region" id="ups-menuPanel2" aria-labelledby="ups-
menuLinks2">
<h2 class="ups-med_show">Services</h2>
<div class="ups-menu_listCols">
Internet Explorer v11 doesn't opens the url on my system but with Selenium v3.12.0, ChromeDriver 2.39 and Chrome v67.0 the following solution clicks on the element with text as Services just perfecto:
Code Block:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.ups.com/us/en/Home.page");
driver.findElement(By.linkText("Services")).click();
Browser Snapshot:
This was tricky for IE , for some reasons all the xpath i tried seems to not work. This might be due to some capabitlites that needs to be added. I haven't looked into it in details but its working for me in Firefox:
String baseURL = "https://www.ups.com/us/en/Home.page";
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "//path to//geckodriver.exe");
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get(baseURL);
Thread.sleep(3000);
WebElement service=driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div/div/div/header/div/nav/ul[1]/li[3]"));
System.out.println(service.getText());
service.click();
If you have issues with your Firefox. Please share the stacktrace so we can help. This code perfectly works for Firefox
webDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();
Thread.sleep(2000);
driver.findElement(By.xpath("html/body/div[1]/section[1]/div/div/a/button")).submit();
'View positions' button is not clicking with the above code.What is happening in the web page?
You see the HTML for this page is
So, you can use the CSS selector for this as
WebDriver driver = new FirefoxDriver();
driver.get("https://www.ignitionone.com/company/careers/");
driver.manage().window().maximize();
Thread.sleep(2000);
driver.findElement(By.cssSelector("button.button.teal").click();
And then proceed with doing whatever is necessary. I executed with this in my Python code and it works fine.
Also, you will need to provide the Gecko executable path while calling for the FirefoxDriver()
The way I have done it before is to use the click handler.
driver.findElement(By.cssSelector(".profile-actions .primary_button > span")).click();
I'm sure you could also select the element by xpath rather than CSS in the above line. It's a similar question to this one.
I want to run a program to perform click on google apps icon using Selenium WebDriver but on running the code, it navigates to google product page.
Pease help me to fix this issue.
driver.get("https://www.google.com");
Thread.sleep(3000);
driver.manage().window().maximize();
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='gbwa']/div[1]/a")).click();
Try this-
driver.findElement(By.xpath("//*[#id='gbwa']")).click();
or
driver.findElement(By.xpath("//*[#id='gbwa']/div[1]")).click();
Please try to click on the link and not on the div.
Use one of these selectors:
Xpath: //*[#id='gbwa']//a[contains(#href, 'options')]
css: #gbwa a[href*=options]
this works for me:
driver.findElement(By.xpath("//a[contains(#class, 'gb_b') and contains(#class, 'gb_4b')]"));
Hope it helps.
System.setProperty("webdriver.chrome.driver", "C:\\driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.findElement(By.cssSelector("div.gb_Lf")).click();
WebElement ele=driver.findElement(By.xpath("//iframe[contains(#id,'I0')]"));
driver.switchTo().frame(ele);
driver.findElement(By.xpath("//*[text()='YouTube']")).click();
I doing automation on a particular website(say xyz.com). When I open the URL manually, it lands me onto a login page as expected and I am able to login there as well.
However, when I am automating the scenario by creating new instance of Firefox using new FirefoxDriver(), login page opens quickly but; when I click on login button it takes almost 2 minutes to navigate to a homepage.
I tried using a new profile but it didnt help.
I am using Selenium 2.44.0 on MAC with Java(Eclipse).
Please help.
I had the same problem with Selenium. What I ended up doing was making the webdriver wait till the page title changes(to homepage) using Expected Conditions.
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.titleContains(": My Expected Page title"));
I would suggest you to have a look here:
driver.wait() throws IllegalMonitorStateException
Wait for page load in Selenium
I am using FirefoxDriver webdriver. The page that loads in Firefox window is a large page and I want to scroll that page using selenium.
I want to know how this can be done.
If you want to scroll on the firefox window using selenium webdriver, one of the way is to use javaScript in the java code, The javeScript code to scroll down is as follows:
WebDriver driver = new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("window.scrollTo(0,Math.max(document.documentElement.scrollHeight," + "document.body.scrollHeight,document.documentElement.clientHeight));");
I think you should do something like
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
Good Luck.
Use this code to scroll single page down
Actions actions = new Actions(driver);
actions.sendKeys(Keys.BACK_SPACE).perform();
page.driver.browser.mouse.move_to( find("element").native,100,100)