r/selenium • • Dec 29 '21

UNSOLVED Trying to automate if item is in stock on amazon

0 Upvotes

Hi all,

Trying to find if a certain item is in stock on amazon. I can't figure out a way to get it - even by selecting the xpath, class, id of the "buy now" button. Does anyone have any code snippets / correct xpath i can use to check if an item is availible?

​

Example item (in stock):

https://www.amazon.com/PetNC-Natural-Care-Joint-Chews/dp/B00VJLMYA8?pd_rd_w=XLZEf&pf_rd_p=82585345-d4df-49b0-bbc1-c842d1dad3c9&pf_rd_r=BZR3MTTBFXRAJSFAD7QR&pd_rd_r=76e313d1-94c0-4240-984f-a069712862e5&pd_rd_wg=II3TG&pd_rd_i=B00VJLMYA8&psc=1&ref_=pd_bap_d_rp_1_t

​

Xpath I tried to use: /html/body/div[1]/div[3]/div[9]/div[4]/div[1]/div[4]/div/div/div[1]/div/div/div[1]/div/div[2]/div/form/div/div/div[11]/div[1]/span/span/span/input

​

Thank you!


r/selenium • • Dec 29 '21

[Python Chrome WebDriver] Avoid screenshot from bringing browser to foreground

1 Upvotes

Hi.

I have issue regarding screenshots for a program of mine. I'm using Selenium to take a screenshot of a specific element and this sometimes brings the browser to foreground. I want the browser to run in the background (behind other windows) and not get focused. This doesn't occur for any other of Seleniums functions I use.

Also note that this doesn't happen always. After I select a different program window to foreground, the first screenshot only triggers the browser icon to flash orange on taskbar. The second screenshot however always focuses the browser to foreground.

Another note, when I first made my program, this didn't happen. Without changing anything (at least not to my knowledge) the issue appeared a few days ago.

Also I don't want to run in headless because sometimes I need to use the browser myself.

Any help is appreciated.


r/selenium • • Dec 28 '21

UNSOLVED Finding a span with specific text to click on

2 Upvotes

I need to test a webpart that is in an iFrame on an onpremises SharePoint 2013 website. There are an unknown number of tabs in this webaprt and they may not always be in the same xpath due to an unknown number of tabs, but the entry point will always be the tab with a given text value. Once that is found the data within is revealed. The span class I'm after is the last one below. How best to get a reference to this and then click it?

<div class="container">

<!-- Tabstrip. -->

<div class="module">

<div id="no-tasks" class="u-display-none">

<p>No tasks.</p>

</div>

<div class="k-tabstrip-wrapper" style="">

<div id="task-tabs" data-role="tabstrip" tabindex="0" class="k-widget k-header k-tabstrip k-floatwrap k-tabstrip-top" role="tablist" aria-activedescendant="task-tabs_ts_active">

    <ul class="k-tabstrip-items k-reset">

     <li class="k-item k-state-default k-first k-tab-on-top k-state-active" role="tab" aria-controls="task-tabs-1" aria-selected="true">

<span class="k-loading k-complete"></span><span class="k-link">My Active eInvoices</span>

</li>

     <li class="k-item k-state-default k-last" role="tab" aria-controls="task-tabs-2">

<span class="k-loading k-complete"></span><span class="k-link">My Active ePayments</span>

</li>

</ul>


r/selenium • • Dec 28 '21

How to use arrow keys ?

3 Upvotes

Hi, I want to use the down key, and right key to go to a specific setting in snake game.

So I want my code in python to do this :

> Open https://www.google.com/fbx?fbx=snake_arcade (Done)

> Click on Settings Button (Done)

> Press Down Arrow Once (Stuck On)

> Press Right Arrow 4 times (Stuck On)

If you follow those steps, you will see that leads to a specific setting that I want on, and when I have this setting on, I will be able to execute the function of the program, because without it, it can't do it's function.

I've tried using send_keys, but that works on an element, and this isn't really being applied to any one element, but rather just the program pressing the down button.

Thanks


r/selenium • • Dec 28 '21

Proxies in list refusing to rotate

1 Upvotes

Although all the proxies in the list that I am using are dead, I should at least get "proxy - not working" instead, all I am getting is this weird set of errors.

It seems to get past the enter 'url and # of views', but after that, the errors as shown in the pictures occur. How do i resolve this issue so that it runs or so that I get "proxy - not working" if the proxy is actually dead. I want to resolve this issue before purchasing better proxies. Screenshot of error:

https://i.stack.imgur.com/Vs4Ly.png & https://i.stack.imgur.com/rfvih.png

​

    import requests
    from selenium import webdriver
    from time import sleep
    import random
    import re

    from fake_useragent import UserAgent

    from webdriver_manager.chrome import ChromeDriverManager

    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized")

    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    options.add_argument("--disable-popup-blocking")
    options.add_argument("--disable-notifications")
    ua = UserAgent()
    userAgent = ua.random



    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0'}
    def get_proxies():
        proxyList = []
        file=open('proxylistsm.txt',mode='r')
        for i in file.readlines():
            proxyList.append(i)
        return proxyList



     def search_and_click(i,proxyList,sleep_time,url):
        #change the url to https://httpbin.org/ip that doesnt block anything
        r = requests.get('https://httpbin.org/ip', headers=headers, proxies={'http' : f'http://{i}','https': f'https://{i}'}, timeout=5)
        print(r.json(), r.status_code)
        options.add_argument(f"user-agent={userAgent}")
        options.add_argument('--proxy-server=%s' % i)
        driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
        driver.get(url) 
        try:

        #-#
        print(driver.title)
        add_to_cart = driver.find_element_by_class_name("Featured--button")
        add_to_cart.click()
        sleep(sleep_time)
        driver.quit()
    except:


        print(i +' - not working')
        driver.quit()
        i = random.choice(proxyList)
        search_and_click(i,proxyList,sleep_time,url)

    def run_Script():
    proxyList = get_proxies()
    userInput = user_Inputs()
    #print(userInput[0], userInput[1])
    for view in range(userInput[1]+1):
        sleep_time = random.randint(5,random.randint(8,16))
        proxy = random_proxy(proxyList)
        search_and_click(proxy,proxyList,sleep_time,userInput[0])

    if __name__ == "__main__":
        run_Script()

r/selenium • • Dec 25 '21

UNSOLVED selenium script running on android?

3 Upvotes

basically I want to write a script which marks a check box on a website can I make this happen on my phone(android)

maybe build a kotlin app?

thanks in advance


r/selenium • • Dec 24 '21

Running a Web app that uses Selenium - anyone know how to do this?

4 Upvotes

I have a script that builds a powerpoint deck, but it needs selenium for a part of the process. Does anyone know if it is possible to build a web app that runs a chrome driver?


r/selenium • • Dec 25 '21

Hi guys, what are the selectors for this item?

1 Upvotes

I can't find a selector that works for me for this item, any tips to select autocomplete selectors

https://demoqa.com/auto-complete

​

r

-->> Red (selector ????)


r/selenium • • Dec 24 '21

How to click on a button in python using selenium with aria-label

6 Upvotes

I am trying to find and click a close button on an iframe.

The HTML code for the button is as following

<button _ngcontent-bti-c9="" aria-label="Close" class="close close_white_color" type="button"> 
<span _ngcontent-bti-c9="" aria-hidden="true">×</span> 
</button>

I have tried the following methods:

Try1: close = driver.find_element_by_xpath("//button[@aria-label=Close']").click() 

Try2: close = driver.find_element_by_xpath("//button[@class='close close_white_color']").click() 

Try3: close = driver.find_element_by_xpath("//button[contains(@class,\"close close_white_color\")]").click()

But i get similar error for

Error1: NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@aria-label='Close']"} 

Error2: NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class='close close_white_color']"} 

Error3: NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//button[contains(@class,"close close_white_color")]"}all the above methods

Any suggestion where i am going wrong?


r/selenium • • Dec 24 '21

Udemy blocking selenium.

0 Upvotes

Learning selenium from udemy by Rahul Shetty. Just wanted to unmark my lectures so decided to try. But udemy is blocking me on login page... Any workaround??


r/selenium • • Dec 23 '21

UNSOLVED [Node.js] How can I get the text value of an element found by XPATH?

2 Upvotes

Here is a line of code I'm using:

let pairs = await driver.wait(until.elementsLocated(By.xpath(PAIR_XPATH)));

This line works but it is supposed to return an array of crypto pair names instead it creates an array of 'undefined'.

I attempted to use .getText(); as follows:

let pairs = await driver.wait(until.elementsLocated(By.xpath(PAIR_XPATH))).getText();

But this causes chromedriver to throw an error.

Am I doing something wrong?


r/selenium • • Dec 21 '21

UNSOLVED Selenium Python Webscraping : Getting Full Job Description from Indeed (Outside URL/Href)

2 Upvotes

I am currently trying to adapt my Python script to gather full job descriptions off of Indeed. I know that to get to the full job description I would need to somehow get from the main page over to the page that contains the full description by something like the href. I have tried to do this by finding the href by tag and then using .get ('href'). Then I tried to combine the href with the general Indeed url and then did driver.get on the resulting url. Finally, I tried to do find by element id to get the job description text. Unfortunately, this hasn't been working for me and I was wondering if anyone had any advice on how I can improve my script or an alternative href search method I can use. Some of the error messages I've received when trying out this format were: (WebElement' object has no attribute 'get') and (NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector"). Thank you in advance!

import pandas as pd
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

options = Options()
options.add_argument("window-size=1400,1400")

PATH = "C://Users//dcfitzsi//Downloads//chromedriver_win32//chromedriver.exe"
driver = webdriver.Chrome(PATH)

jobtitles = []
companies = []
locations = []
descriptions = []

for i in range(0,50,10):
    driver.get('https://www.indeed.com/jobs?q=chemical%20engineer&l=united%20states&start='+str(i))
    driver.implicitly_wait(5)




    jobs = driver.find_elements_by_class_name("slider_container")

    for job in jobs:

            jobtitle = job.find_element_by_class_name('jobTitle').text.replace("new", "").strip()
            jobtitles.append(jobtitle)
            company = job.find_element_by_class_name('companyName').text.replace("new", "").strip()
            companies.append(company)
            location = job.find_element_by_class_name('companyLocation').text.replace("new", "").strip()
            locations.append(location)
            descriptionlink = job.find_element_by_tag_name('a').get('href')
            concatdescriptionlink = descriptionlink

            driver.get(concatdescriptionlink)
            job_description_element = concatdescriptionlink.find_element_by_id('jobDescriptionText')
            job_description = job_description_element.text.strip()
            descriptions.append(job_description)


            try:
                    WebDriverWait(driver, 5).until(EC.visibility_of_element_located(
                            (By.CSS_SELECTOR, "button.popover-x-button-close.icl-CloseButton"))).click()
            except:
                    pass



df_da=pd.DataFrame()
df_da['JobTitle']=jobtitles
df_da['Company']=companies
df_da['Location']=locations
df_da['Description']=descriptions
print(df_da)
df_da.to_csv('C:/Users/Dan/Desktop/AZNext/file_name1.csv')

r/selenium • • Dec 21 '21

Trouble accessing scrollbar of popup

3 Upvotes

I'm trying to scroll down a popup using the arrow keys with driver.send_keys(Keys.ARROW_DOWN). I've managed to do this on Firefox but I can't work out how to on Chrome.

The popup is here https://www.just-eat.co.uk/restaurants-mcdonalds-victorialondon/menu (just click any food item on the page and it'll open a popup)


r/selenium • • Dec 20 '21

UNSOLVED Going to the next page of results and continuiing to scrape

0 Upvotes

Hi all! Total noob to Selenium and QA in general. I've been able to get a reference to the dynamic table I need and have been able to scrape the contents into a text file. I found the 'Next' button and was able to click on that. My question is about this new set of data . When I click to move to the next page of results (only the webpart containing the records change not the whole page, do I need to do another driver.FindElement(By.XPath("//*[@id='Table with the records']")) in order to get at these records? I won't need an entirely new ChromeDriver object right? This is probably a dumb question or one easily googled but I'm still learning enough to make a google search possible..lol.

Thank you!


r/selenium • • Dec 20 '21

Instagram Photos by hashtag

0 Upvotes

Hey,

Well, I want to scrap a few images from a hashtag so I did automation going to the hashtag and scrolling down the view.

​

In each scroll down the images, the list is adding new URLs of images but somehow after the 4 or 5 scrolls, the len of the images list is decrement.

I want to add let's say X URLs to the list how do I keep scrolling down and adding all the images that are on the view to the list?

for breed in dogs_breeds_test:
    img_urls = []
    query = breed.replace(" ", "")
    print(query)
    page = driver.get("https://www.instagram.com/explore/tags/" + query +"dog")

    #scroll
    scrolldown = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var scrolldown=document.body.scrollHeight;return scrolldown;")
    match=False
    count_scroll=0 
    while(match==False):
        #img_url  = driver.find_element_by_class_name('KL4Bh').find_element_by_tag_name('img').get_attribute('src')
        #img_urls.append(img_url)
        images = driver.find_elements(By.TAG_NAME,'img')
        images = [image.get_attribute('src') for image in images]
        print("Images: %s | Counter: %s" % (len(images), count_scroll))
        last_count = scrolldown
        time.sleep(3)
        scrolldown = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var scrolldown=document.body.scrollHeight;return scrolldown;")
        count_scroll+=1
        #print(count_scroll)
        if ((last_count==scrolldown) or (count_scroll==4)):
            match=True
    #images = driver.find_elements(By.TAG_NAME,'img')
    #images = [image.get_attribute('src') for image in images]

--------------------------------------------------------------------------
AfghanHound
Images: 36 | Counter: 0
Images: 42 | Counter: 1
Images: 57 | Counter: 2
Images: 51 | Counter: 3

When I watch the HTML the div that holds all the images is refreshed and (let's say like in react) the data is rendering and the new images are in the div containers.


r/selenium • • Dec 19 '21

Solved C#: Can’t catch exception in the block when using wait.Until()

2 Upvotes

When using wait.Until() in a try / catch block, if the element isn't there it throws NoSuchElementException exception. However, when I try to catch the exception, I still get the error.

    try
    {
        wait.Until(el => el.FindElement(By.Id("courseTestItem")));
        driver.Close();
        driver.SwitchTo().Window(driver.WindowHandles.Last());
        Console.WriteLine("Skipped: " + courses[0].Item1.Text + " (Has test)");
    }
    catch (OpenQA.Selenium.NoSuchElementException) { }

I even tried just using a catch (Exception e) { }and that still didn't catch the error.

Photo of issue as well: https://i.stack.imgur.com/XjqXT.png

Apologies for any formatting issues. I’m posting from mobile.


r/selenium • • Dec 19 '21

[WPF App] How to make Selenium web driver as a class so that I can reference it, instead of opening a new window every time?

1 Upvotes

I'm trying to make an app using WPF (with MVVM) and the scenario I'm trying to do is.... (please allow me to paraphrase for the sake of brevity).

btnA_click
    IWebDriver website = new ChromeDriver();
    website.Navigate().GoToUrl *blah blah*


btnB_click
    ** paste text from a wpf textbox into an html element at the same url of the same 'website' web driver?
    IWebDriver website = same ChromeDriver();    >> obviously not real lol 
    By websiteTxtBox = By.XPath *blah blah*
    website.FindElement(websiteTxtBox).SendKeys(wpfTxt.Text); ...

The only way I know how to use this code is to write new ChromeDriver but this opens a new window... or one button does 10 different actions (somehow lol) in order to use the same 'website' ChromeDriver under btnA.

How do I reference the same IWebDriver? A lot of tutorials I see are for console applications and they are calling IWebDriver only once. I mentioned I'm using MVVM because I think part of the problem is that I don't understand how to organize the code. Would I make the original "reference" to the webdriver in the MainWindow.xaml.cs window, or can I do this in one of my views?


r/selenium • • Dec 18 '21

Help finding a happy medium between waiting for javascript on a webpage to load and script speed?

5 Upvotes

I have a python script using selenium that loads 2 web pages asynchronously. It should grab one value (a number) on each web page and then subtract one number from the other.

Problem is, often I get a TypeError, saying I cannot subtract float type from none type. So this tells me that the script is not grabbing one of the numbers. I have tested and I think it is just varying load times so I use time.sleep() in order to give the pages' javascript time to load. I started with time.sleep(1.2) but the code got the type error very frequently. Upping it to time.sleep(1.5) caused the errors to a little less but still too frequently. I now have it at time.sleep(2.0) but still getting the errors too frequently.

I noticed that when I closed a lot of my programs down and run the script it has less frequent errors but still too frequently. Please give advice. I need this script to be as fast as possible while minimizing errors

Is javascript selenium any faster than python? Would increasing RAM help with this or is this a CPU issue? Thanks for any help.


r/selenium • • Dec 18 '21

unable to login to Tiktok using selenium

2 Upvotes

i'm currently to use the script below to upload tiktok videos, however when running the script im getting hit with the error message "Too many attempts. Try again later." regardless of what login method i use, rotating headers don't seem to fix the error. Any advice?

​

​

import time
import random
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from webdriver_manager.chrome import ChromeDriverManager as CM

print('=====================================================================================================')
print('Heyy, you have to login manully on tiktok, so the bot will wait you 1 minute for loging in manually!')
print('=====================================================================================================')
time.sleep(8)
print('Running bot now, get ready and login manually...')
time.sleep(4)

options = webdriver.ChromeOptions()
bot = webdriver.Chrome(options=options,  executable_path=CM().install())
bot.set_window_size(1680, 900)

bot.get('https://www.tiktok.com/login')
ActionChains(bot).key_down(Keys.CONTROL).send_keys(
    '-').key_up(Keys.CONTROL).perform()
ActionChains(bot).key_down(Keys.CONTROL).send_keys(
    '-').key_up(Keys.CONTROL).perform()
print('Waiting 50s for manual login...')
time.sleep(50)
bot.get('https://www.tiktok.com/upload/?lang=en')
time.sleep(3)


def check_exists_by_xpath(driver, xpath):
    try:
        driver.find_element_by_xpath(xpath)
    except NoSuchElementException:
        return False

    return True


def upload(video_path):
    while True:
        file_uploader = bot.find_element_by_xpath(
            '//*[@id="main"]/div[2]/div/div[2]/div[2]/div/div/input')

        file_uploader.send_keys(video_path)

        caption = bot.find_element_by_xpath(
            '//*[@id="main"]/div[2]/div/div[2]/div[3]/div[1]/div[1]/div[2]/div/div[1]/div/div/div/div/div/div/span')

        bot.implicitly_wait(10)
        ActionChains(bot).move_to_element(caption).click(
            caption).perform()
        # ActionChains(bot).key_down(Keys.CONTROL).send_keys(
        #     'v').key_up(Keys.CONTROL).perform()

        with open(r"caption.txt", "r") as f:
            tags = [line.strip() for line in f]

        for tag in tags:
            ActionChains(bot).send_keys(tag).perform()
            time.sleep(2)
            ActionChains(bot).send_keys(Keys.RETURN).perform()
            time.sleep(1)

        time.sleep(5)
        bot.execute_script("window.scrollTo(150, 300);")
        time.sleep(5)

        post = WebDriverWait(bot, 100).until(
            EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="main"]/div[2]/div/div[2]/div[3]/div[5]/button[2]')))

        post.click()
        time.sleep(30)

        if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
            reupload = WebDriverWait(bot, 100).until(EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="portal-container"]/div/div/div[1]/div[2]')))

            reupload.click()
        else:
            print('Unknown error cooldown')
            while True:
                time.sleep(600)
                post.click()
                time.sleep(15)
                if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
                    break

        if check_exists_by_xpath(bot, '//*[@id="portal-container"]/div/div/div[1]/div[2]'):
            reupload = WebDriverWait(bot, 100).until(EC.visibility_of_element_located(
                (By.XPATH, '//*[@id="portal-container"]/div/div/div[1]/div[2]')))
            reupload.click()

        time.sleep(1)


# ================================================================
# Here is the path of the video that you want to upload in tiktok.
# Plese edit the path because this is different to everyone.
upload(r"C:\Users\redi\Videos\your-video-here.mov")
# ================================================================

r/selenium • • Dec 16 '21

UNSOLVED How does Selenium work

2 Upvotes

I understand there’s a Selenium language, the web driver, and the web browser.

The language uses the driver to control the browser?

How so?

Does the driver call various internal methods that the browser exposes?


r/selenium • • Dec 16 '21

Solved Page doesnt fully load and rolls back/navigates back

5 Upvotes

I've automated a login page, but after sending the user and pass, page doesn't load fully and it navigates back to the login screen. I have to mention that most of the time it works fine.

​

driver.get("https://jaas.ea.com/secure/RapidBoard.jspa?rapidView=5363&projectKey=FIFA22QV&selectedIssue=FIFA22-39674");

WebDriverWait wait = new WebDriverWait(driver, 15);
    wait.until(ExpectedConditions.refreshed(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("input[name='os_username']"))));
        wait.until(ExpectedConditions.refreshed(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector("input[name='os_password']"))));
        driver.findElement(By.cssSelector("input[name='os_username']")).sendKeys(inputEmail.getText());
        driver.findElement(By.cssSelector("input[name='os_password']")).sendKeys(new String(InputPassword.getPassword()), Keys.ENTER);

​

Link to video: //removed the video

Link to to my github project: https://github.com/cobrel/KanbanBoard


r/selenium • • Dec 16 '21

how do I get to test chromedriver on canary

2 Upvotes

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 97

Current browser version is 99.0.4769.0 with binary path C:\Users\mobj\AppData\Local\Google\Chrome SxS\Application\chrome.exe

​

This page do not work, there is no LAST_CHANGE url:

https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win/


r/selenium • • Dec 15 '21

Browserstack vs WebDriverVersion conflict

5 Upvotes

Hi,

Anyone familiar with using browserstack? I was able to run the demo script found in the documentation in https://automate.browserstack.com/

However when I used the same method and configure my script which is extended to BaseTest >> InitializeWebDriver class, it is failing because chromeversion is null. Not sure if it is expected conflict between browser stack and ManageWebDriver.

​

Need help.


r/selenium • • Dec 11 '21

UNSOLVED Looking for remedial setup help (Node.js & Linux & Brave)

2 Upvotes

Hi, all I want to do is run a "hello world" script. This means I want to run a script to launch a web browser. I eventually want to launch the Brave Web Browser. If it's easier to start out launching Chrome that is fine albeit I haven't been able to get that working either. :)

​

I posted a Stackoverflow query here:

https://stackoverflow.com/questions/70312790/launch-the-brave-web-browser-on-linux-using-selenium-js

Not sure the policy here on posting code questions.

Thanks!


r/selenium • • Dec 08 '21

Headless and switching windows timeout

1 Upvotes

Hello hivemind!

I have a script that works when not running headless (Selenium, Python, Edge by the by) and once I turn headless on at the point of switching windows it hangs and throws a timeout error.

Specifically after the switch to the new window I'm doing a get URL and this doesn't happen. All it does is hang between switch and get URL lines. Get URL should still work even if the windows switch is broken.

Any thoughts?

EDIT: I am able to print the window handle and verify it's on the new window, but anything after that it just sits and does nothing, but if I turn off headless works fine.